Skip to content

Commit

Permalink
Allow usage of "super()" statement in constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed Jan 24, 2022
1 parent 1be2957 commit f8f735d
Show file tree
Hide file tree
Showing 58 changed files with 260 additions and 223 deletions.
2 changes: 1 addition & 1 deletion javatools/src/main/java/org/xvm/compiler/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ public static Stage valueOf(int i)
*/
public static final String NO_THIS = "COMPILER-52";
/**
* There is no "super".
* No "super" method is available.
*/
public static final String NO_SUPER = "COMPILER-53";
/**
Expand Down
220 changes: 126 additions & 94 deletions javatools/src/main/java/org/xvm/compiler/ast/InvocationExpression.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javatools/src/main/resources/errors.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ COMPILER-49 = A return is required.
COMPILER-50 = Could not find an operation resulting in \"{0}\" type.
COMPILER-51 = Variable \"{0}\" is already defined.
COMPILER-52 = No \"this\" is available.
COMPILER-53 = No \"super\" function is available.
COMPILER-53 = No \"super\" method is available.
COMPILER-54 = The contribution type \"{0}\" must be parameterized.
COMPILER-55 = Method or function type requires complete parameter and return type information.
COMPILER-56 = Could not find a matching method or function \"{0}\" for type \"{1}\".
Expand Down
2 changes: 1 addition & 1 deletion javatools_bridge/src/main/x/_native/fs/CPDirectory.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CPDirectory(Object cookie, CPFileStore? fileStore, Path path, DateTime cre
{
construct (Object cookie)
{
construct CPFileNode(cookie);
super(cookie);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion javatools_bridge/src/main/x/_native/fs/CPFile.x
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CPFile(Object cookie, CPFileStore? fileStore, Path path, DateTime created,
{
construct (Object cookie)
{
construct CPFileNode(cookie);
super(cookie);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions lib_collections/src/main/x/collections/ConcurrentHashMap.x
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ConcurrentHashMap<Key extends immutable Hashable, Value extends Shareable>
construct(Int initCapacity = 0, Int parallelism = 16)
{
assert Hasher<Key> hasher := Key.hashed();
construct ConcurrentHasherMap(hasher, initCapacity, parallelism);
super(hasher, initCapacity, parallelism);
}

/**
Expand All @@ -40,7 +40,7 @@ const ConcurrentHashMap<Key extends immutable Hashable, Value extends Shareable>
construct(Map<Key, Value> that, Int parallelism = 16)
{
assert Hasher<Key> hasher := Key.hashed();
construct ConcurrentHasherMap(hasher, that, parallelism);
super(hasher, that, parallelism);
}

/**
Expand All @@ -51,6 +51,6 @@ const ConcurrentHashMap<Key extends immutable Hashable, Value extends Shareable>
*/
construct(ConcurrentHashMap<Key, Value> that, Int parallelism = 16)
{
construct ConcurrentHasherMap(that, parallelism);
super(that, parallelism);
}
}
6 changes: 3 additions & 3 deletions lib_collections/src/main/x/collections/ConcurrentHasherMap.x
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ const ConcurrentHasherMap<Key extends immutable Object, Value extends Shareable>
{
construct (Iterator<Element> iter1, Iterator<Element> iter2)
{
construct CompoundIterator(iter1, iter2);
super(iter1, iter2);
}
}

Expand Down Expand Up @@ -472,7 +472,7 @@ const ConcurrentHasherMap<Key extends immutable Object, Value extends Shareable>
assert partitionCount > 0 as "Partition count must be specified";

this.partitionCount = partitionCount;
construct HasherMap(hasher, initCapacity);
super(hasher, initCapacity);
}

/**
Expand All @@ -483,7 +483,7 @@ const ConcurrentHasherMap<Key extends immutable Object, Value extends Shareable>
construct(Partition<Key, Value> that)
{
this.partitionCount = that.partitionCount;
construct HasherMap(that);
super(that);
}


Expand Down
6 changes: 3 additions & 3 deletions lib_ecstasy/src/main/x/ecstasy/collections/HashMap.x
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HashMap<Key extends Hashable, Value>
construct(Map<Key, Value> that)
{
assert Hasher<Key> hasher := Key.hashed();
construct HasherMap(hasher, that);
super(hasher, that);
}

/**
Expand All @@ -43,7 +43,7 @@ class HashMap<Key extends Hashable, Value>
*/
construct(HashMap<Key, Value> that)
{
construct HasherMap(that);
super(that);
}

/**
Expand All @@ -55,6 +55,6 @@ class HashMap<Key extends Hashable, Value>
*/
construct(Hasher<Key> hasher, Int initCapacity = 0)
{
construct HasherMap(hasher, initCapacity);
super(hasher, initCapacity);
}
}
6 changes: 3 additions & 3 deletions lib_ecstasy/src/main/x/ecstasy/collections/HashSet.x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HashSet<Element extends Hashable>
*/
construct(Int initCapacity = 0)
{
construct MapSet(new HashMap<Element, Nullable>(initCapacity));
super(new HashMap<Element, Nullable>(initCapacity));
}

/**
Expand All @@ -34,7 +34,7 @@ class HashSet<Element extends Hashable>
{
map.put(value, Null);
}
construct MapSet(map);
super(map);
}
}

Expand All @@ -45,6 +45,6 @@ class HashSet<Element extends Hashable>
*/
construct(HashSet<Element> that)
{
construct MapSet(that);
super(that);
}
}
6 changes: 3 additions & 3 deletions lib_ecstasy/src/main/x/ecstasy/collections/HasherSet.x
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HasherSet<Element>
*/
construct(Hasher<Element> hasher, Int initCapacity = 0)
{
construct MapSet(new HasherMap<Element, Nullable>(hasher, initCapacity));
super(new HasherMap<Element, Nullable>(hasher, initCapacity));
}

/**
Expand All @@ -36,7 +36,7 @@ class HasherSet<Element>
{
map.put(value, Null);
}
construct MapSet(map);
super(map);
}
}

Expand All @@ -47,7 +47,7 @@ class HasherSet<Element>
*/
construct(HasherSet<Element> that)
{
construct MapSet(that);
super(that);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/collections/ListSet.x
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ListSet<Element>
{
map.put(value, Null);
}
construct MapSet(map);
super(map);
}

/**
Expand All @@ -30,6 +30,6 @@ class ListSet<Element>
*/
construct(ListSet<Element> that)
{
construct MapSet(that);
super(that);
}
}
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/collections/OrderedMapSet.x
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OrderedMapSet<Element extends Orderable>
*/
construct(CopyableOrderedMap map)
{
construct MapSet(map);
super(map);
}

/**
Expand All @@ -27,7 +27,7 @@ class OrderedMapSet<Element extends Orderable>
*/
construct(OrderedMapSet<Element> that)
{
construct MapSet(that);
super(that);
}


Expand Down
14 changes: 2 additions & 12 deletions lib_ecstasy/src/main/x/ecstasy/collections/SkiplistMap.x
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,6 @@ class SkiplistMap<Key extends Orderable, Value>
@Override
protected class IteratorImpl
{
construct()
{
construct CollectionImpl.IteratorImpl(); // TODO GG super()
}

@Override
protected Key toElement(Key key, Int node, Int height)
{
Expand Down Expand Up @@ -737,11 +732,6 @@ class SkiplistMap<Key extends Orderable, Value>
@Override
protected class IteratorImpl
{
construct()
{
construct CollectionImpl.IteratorImpl(); // TODO GG super()
}

@Override
protected Entry toElement(Key key, Int node, Int height)
{
Expand Down Expand Up @@ -2513,7 +2503,7 @@ class SkiplistMap<Key extends Orderable, Value>
{
construct()
{
construct AbstractStore();
super();

// determine the size of the numeric type
Type numType;
Expand Down Expand Up @@ -2690,7 +2680,7 @@ class SkiplistMap<Key extends Orderable, Value>
{
construct(Int initCapacity)
{
construct AbstractStore();
super();
contents = new Array<Element|Int>(initCapacity);
}

Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/collections/SkiplistSet.x
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SkiplistSet<Element extends Orderable>
*/
construct(Int initialCapacity = 0, Orderer? orderer = Null)
{
construct OrderedMapSet(new SkiplistMap<Element, Nullable>(initialCapacity, orderer));
super(new SkiplistMap<Element, Nullable>(initialCapacity, orderer));
}

/**
Expand All @@ -30,6 +30,6 @@ class SkiplistSet<Element extends Orderable>
*/
construct(SkiplistSet<Element> that)
{
construct OrderedMapSet(that);
super(that);
}
}
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/fs/DirectoryFileStore.x
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const DirectoryFileStore(Directory origDir, Boolean readOnly = False)
{
construct(Directory origDir)
{
construct FileNodeWrapper(origDir);
super(origDir);
}

protected Directory origDir.get()
Expand Down Expand Up @@ -400,7 +400,7 @@ const DirectoryFileStore(Directory origDir, Boolean readOnly = False)
{
construct(File origFile)
{
construct FileNodeWrapper(origFile);
super(origFile);
}

protected File origFile.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FilteredIterator<Element>
construct(Iterator<Element> iter, function Boolean include(Element))
{
this.include = include;
construct DelegatingIterator(iter);
super(iter);
}

protected/private function Boolean include(Element);
Expand Down
2 changes: 1 addition & 1 deletion lib_ecstasy/src/main/x/ecstasy/iterators/LimitedIterator.x
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LimitedIterator<Element>
construct(Iterator<Element> iter, Int remain)
{
this.remain = remain;
construct DelegatingIterator(iter);
super(iter);
}

protected/private Int remain;
Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/numbers/BFloat16.x
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const BFloat16
construct(Bit[] bits)
{
assert:bounds bits.size == 16;
construct BinaryFPNumber(bits);
super(bits);
}

/**
Expand All @@ -25,7 +25,7 @@ const BFloat16
construct(Byte[] bytes)
{
assert:bounds bytes.size == 2;
construct BinaryFPNumber(bytes);
super(bytes);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/numbers/BinaryFPNumber.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
construct(Bit[] bits)
{
construct FPNumber(bits);
super(bits);
}

/**
Expand All @@ -27,7 +27,7 @@
*/
construct(Byte[] bytes)
{
construct FPNumber(bytes);
super(bytes);
}


Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/numbers/Dec128.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Dec128
construct(Bit[] bits)
{
assert:bounds bits.size == 128;
construct DecimalFPNumber(bits);
super(bits);
}

/**
Expand All @@ -24,7 +24,7 @@ const Dec128
construct(Byte[] bytes)
{
assert:bounds bytes.size == 16;
construct DecimalFPNumber(bytes);
super(bytes);
}


Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/numbers/Dec32.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Dec32
construct(Bit[] bits)
{
assert:bounds bits.size == 32;
construct DecimalFPNumber(bits);
super(bits);
}

/**
Expand All @@ -24,7 +24,7 @@ const Dec32
construct(Byte[] bytes)
{
assert:bounds bytes.size == 4;
construct DecimalFPNumber(bytes);
super(bytes);
}


Expand Down
4 changes: 2 additions & 2 deletions lib_ecstasy/src/main/x/ecstasy/numbers/Dec64.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Dec64
construct(Bit[] bits)
{
assert:bounds bits.size == 64;
construct DecimalFPNumber(bits);
super(bits);
}

/**
Expand All @@ -24,7 +24,7 @@ const Dec64
construct(Byte[] bytes)
{
assert:bounds bytes.size == 8;
construct DecimalFPNumber(bytes);
super(bytes);
}


Expand Down
Loading

0 comments on commit f8f735d

Please sign in to comment.