java-commons/muscript/src/main/java/io/gitlab/jfronny/muscript/compiler/expr/DynamicExpr.java

40 lines
950 B
Java
Raw Normal View History

package io.gitlab.jfronny.muscript.compiler.expr;
import io.gitlab.jfronny.commons.data.dynamic.Dynamic;
import io.gitlab.jfronny.muscript.compiler.Type;
import io.gitlab.jfronny.muscript.compiler.expr.dynamic.unpack.*;
public abstract non-sealed class DynamicExpr extends Expr<Dynamic<?>> {
2023-01-20 17:47:41 +01:00
protected DynamicExpr(int chStart, int chEnd) {
super(chStart, chEnd);
2022-06-13 13:31:54 +02:00
}
@Override
public Type getResultType() {
return Type.Dynamic;
}
@Override
public abstract DynamicExpr optimize();
@Override
public BoolExpr asBoolExpr() {
2023-01-20 17:47:41 +01:00
return new BoolUnpack(chStart, chEnd, this);
}
@Override
public StringExpr asStringExpr() {
2023-01-20 17:47:41 +01:00
return new StringUnpack(chStart, chEnd, this);
}
@Override
public NumberExpr asNumberExpr() {
2023-01-20 17:47:41 +01:00
return new NumberUnpack(chStart, chEnd, this);
}
@Override
public DynamicExpr asDynamicExpr() {
return this;
}
}