Search in sources :

Example 11 with IPartialExpression

use of stanhebben.zenscript.expression.partial.IPartialExpression in project ZenScript by CraftTweaker.

the class ParsedExpressionOpAssign method compile.

@Override
public IPartialExpression compile(IEnvironmentMethod environment, ZenType predictedType) {
    // TODO: validate if the prediction rules are sound
    Expression cLeft = left.compile(environment, predictedType).eval(environment);
    Expression cRight = right.compile(environment, cLeft.getType()).eval(environment);
    Expression value = cLeft.getType().binary(getPosition(), environment, cLeft, cRight, operator);
    return left.compile(environment, predictedType).assign(getPosition(), environment, value);
}
Also used : Expression(stanhebben.zenscript.expression.Expression) IPartialExpression(stanhebben.zenscript.expression.partial.IPartialExpression)

Aggregations

IPartialExpression (stanhebben.zenscript.expression.partial.IPartialExpression)11 Expression (stanhebben.zenscript.expression.Expression)6 ZenType (stanhebben.zenscript.type.ZenType)2 ICastingRule (stanhebben.zenscript.type.casting.ICastingRule)2