-
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.
Fix concrete usages of generic functional interfaces
- Loading branch information
1 parent
b2713f0
commit d76a28d
Showing
9 changed files
with
144 additions
and
24 deletions.
There are no files selected for viewing
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
69 changes: 69 additions & 0 deletions
69
...Shared/src/main/java/org/openzen/zenscript/javashared/prepare/JavaPrepareTypeVisitor.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,69 @@ | ||
package org.openzen.zenscript.javashared.prepare; | ||
|
||
import org.openzen.zenscript.codemodel.type.*; | ||
import org.openzen.zenscript.javashared.JavaContext; | ||
|
||
public class JavaPrepareTypeVisitor implements TypeVisitor<Void> { | ||
private final JavaContext context; | ||
|
||
public JavaPrepareTypeVisitor(JavaContext context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public Void visitBasic(BasicTypeID basic) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitArray(ArrayTypeID array) { | ||
return array.elementType.accept(this); | ||
} | ||
|
||
@Override | ||
public Void visitAssoc(AssocTypeID assoc) { | ||
assoc.keyType.accept(this); | ||
assoc.valueType.accept(this); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitGenericMap(GenericMapTypeID map) { | ||
map.value.accept(this); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitIterator(IteratorTypeID iterator) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitFunction(FunctionTypeID function) { | ||
context.getFunction(function); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitDefinition(DefinitionTypeID definition) { | ||
for (TypeID argument : definition.typeArguments) | ||
argument.accept(this); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitGeneric(GenericTypeID generic) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitRange(RangeTypeID range) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitOptional(OptionalTypeID type) { | ||
type.baseType.accept(this); | ||
return null; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
ScriptingEngineTester/src/main/resources/zencode-tests/lambdas/lambda-string-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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#output: Hello | ||
|
||
var accept as function(value: string): void = (value) => println(value); | ||
accept("Hello"); |
4 changes: 4 additions & 0 deletions
4
ScriptingEngineTester/src/main/resources/zencode-tests/lambdas/lambda-string-2.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#output: Hello | ||
|
||
var accept as function(value: string, x: int, y: int): void = (value, x, y) => println(value); | ||
accept("Hello", 0, 0); |
1 change: 0 additions & 1 deletion
1
ScriptingEngineTester/src/main/resources/zencode-tests/variants/optional-ifpresent-empty.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,4 +1,3 @@ | ||
#output: Hello world | ||
|
||
public variant Optional<T> { | ||
Present(T), | ||
|
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