-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement iterators on optional types
- Loading branch information
1 parent
deff1f5
commit a29b19f
Showing
5 changed files
with
122 additions
and
37 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...el/src/main/java/org/openzen/zenscript/codemodel/type/builtin/OptionalIteratorMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.openzen.zenscript.codemodel.type.builtin; | ||
|
||
import org.openzen.zenscript.codemodel.FunctionHeader; | ||
import org.openzen.zenscript.codemodel.Modifiers; | ||
import org.openzen.zenscript.codemodel.identifiers.DefinitionSymbol; | ||
import org.openzen.zenscript.codemodel.identifiers.MethodID; | ||
import org.openzen.zenscript.codemodel.identifiers.MethodSymbol; | ||
import org.openzen.zenscript.codemodel.identifiers.instances.MethodInstance; | ||
import org.openzen.zenscript.codemodel.type.OptionalTypeID; | ||
import org.openzen.zenscript.codemodel.type.TypeID; | ||
|
||
import java.util.Optional; | ||
|
||
public class OptionalIteratorMethod implements MethodSymbol { | ||
public final MethodSymbol original; | ||
|
||
public OptionalIteratorMethod(MethodSymbol original) { | ||
this.original = original; | ||
} | ||
|
||
@Override | ||
public DefinitionSymbol getDefiningType() { | ||
return original.getDefiningType(); | ||
} | ||
|
||
@Override | ||
public TypeID getTargetType() { | ||
return new OptionalTypeID(original.getTargetType()); | ||
} | ||
|
||
@Override | ||
public Modifiers getModifiers() { | ||
return original.getModifiers(); | ||
} | ||
|
||
@Override | ||
public MethodID getID() { | ||
return original.getID(); | ||
} | ||
|
||
@Override | ||
public FunctionHeader getHeader() { | ||
return original.getHeader(); | ||
} | ||
|
||
@Override | ||
public Optional<MethodInstance> getOverrides() { | ||
return original.getOverrides(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
ScriptingEngineTester/src/main/resources/zencode_tests/arrays/sort_1.zc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
#dependency: stdlib | ||
#output: [1, 2, 3, 4, 5] | ||
#output: 1 | ||
#output: 2 | ||
#output: 3 | ||
#output: 4 | ||
#output: 5 | ||
|
||
val a = [5, 1, 2, 4, 3]; | ||
a.sort(); | ||
println(a); | ||
|
||
for element in a { | ||
println(element); | ||
} |