
com.github.bloodshura.ignitium.venus.expression.InContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of venusscript Show documentation
Show all versions of venusscript Show documentation
A dynamic, easy, highly customizable scripting language.
The newest version!
package com.github.bloodshura.ignitium.venus.expression;
import com.github.bloodshura.ignitium.venus.exception.runtime.InvalidValueTypeException;
import com.github.bloodshura.ignitium.venus.exception.runtime.ScriptRuntimeException;
import com.github.bloodshura.ignitium.venus.executor.Context;
import com.github.bloodshura.ignitium.venus.value.ObjectValue;
import com.github.bloodshura.ignitium.venus.value.Value;
public class InContext implements Expression {
private final Expression expression;
private final String name;
public InContext(String name, Expression expression) {
this.name = name;
this.expression = expression;
}
public Expression getExpression() {
return expression;
}
public String getName() {
return name;
}
@Override
public Value resolve(Context context) throws ScriptRuntimeException {
Value value = context.getVarValue(getName());
if (value instanceof ObjectValue) {
ObjectValue object = (ObjectValue) value;
return getExpression().resolve(object.getContext()); // See issue #24
} else {
throw new InvalidValueTypeException(context, getName() + " has type " + value.getType() + "; expected to be an object");
}
}
@Override
public String toString() {
return "incontext(" + getName() + " << " + getExpression() + ')';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy