mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-19 11:49:05 +00:00
- Rewrote the whole damn typecasting system. Now uses a more flexible and more structure casting rule system.
- Improved function literals. Function recipes are a thing! - Added mirrored shaped recipes - Fixed a few "any" type - related errors - Added environment to the bracket handlers. Breaks existing bracket handlers!! - Turned JavaMethod into an interface. Can now be used both for existing methods and generated ones. Makes a few things simpler :) - Added creative and adventure getters to player info
This commit is contained in:
1 parent
c67ad22270
commit
154c2242f9
172 files changed
+5400
-2134
No files matched your search
@@ -8,13 +8,13 @@ import stanhebben.zenscript.expression.partial.IPartialExpression;
|
||||
import stanhebben.zenscript.parser.expression.ParsedExpression;
|
||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||
import stanhebben.zenscript.type.ZenType;
|
||||
import stanhebben.zenscript.type.ZenTypeBool;
|
||||
import stanhebben.zenscript.type.casting.ICastingRule;
|
||||
import stanhebben.zenscript.util.ZenPosition;
|
||||
|
||||
public abstract class Expression implements IPartialExpression {
|
||||
public static final Expression parse(ZenTokener parser, IEnvironmentMethod environment) {
|
||||
public static final Expression parse(ZenTokener parser, IEnvironmentMethod environment, ZenType predictedType) {
|
||||
return ParsedExpression.read(parser, environment)
|
||||
.compile(environment)
|
||||
.compile(environment, predictedType)
|
||||
.eval(environment);
|
||||
}
|
||||
|
||||
@@ -28,13 +28,17 @@ public abstract class Expression implements IPartialExpression {
|
||||
return position;
|
||||
}
|
||||
|
||||
public abstract ZenType getType();
|
||||
|
||||
public Expression cast(ZenPosition position, IEnvironmentGlobal environment, ZenType type) {
|
||||
if (getType() == type) {
|
||||
return this;
|
||||
} else {
|
||||
return getType().cast(position, environment, this, type);
|
||||
ICastingRule castingRule = getType().getCastingRule(type, environment);
|
||||
if (castingRule == null) {
|
||||
environment.error(position, "Cannot cast " + this.getType() + " to " + type);
|
||||
return new ExpressionInvalid(position, type);
|
||||
} else {
|
||||
return new ExpressionAs(position, this, castingRule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +81,11 @@ public abstract class Expression implements IPartialExpression {
|
||||
return getType().call(position, environment, this, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZenType[] predictCallTypes(int numArguments) {
|
||||
return getType().predictCallTypes(numArguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZenSymbol toSymbol() {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user