org.snapscript.tree.define.ClassPropertyGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.define;
import static org.snapscript.core.Reserved.TYPE_CLASS;
import static org.snapscript.core.variable.Constant.TYPE;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.scope.ScopeState;
import org.snapscript.core.type.Type;
import org.snapscript.core.type.TypeBody;
import org.snapscript.core.variable.Value;
public class ClassPropertyGenerator {
private final ConstantPropertyBuilder builder;
public ClassPropertyGenerator() {
this.builder = new ConstantPropertyBuilder();
}
public void generate(TypeBody body, Scope scope, Type type) throws Exception {
Value value = Value.getConstant(type, TYPE);
Scope outer = type.getScope();
ScopeState state = outer.getState();
builder.createStaticProperty(body, TYPE_CLASS, type, TYPE);
state.addValue(TYPE_CLASS, value);
}
}