All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.define.ClassPropertyGenerator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.tree.define;

import static org.snapscript.core.ModifierType.CONSTANT;
import static org.snapscript.core.Reserved.TYPE_CLASS;
import static org.snapscript.core.Reserved.TYPE_THIS;
import static org.snapscript.core.variable.Constant.TYPE;

import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.scope.State;
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 {
      Constraint constraint = Constraint.getConstraint(type, CONSTANT.mask);
      Value value = Value.getConstant(type, TYPE);
      Scope outer = type.getScope();
      State state = outer.getState();
      
      builder.createInstanceProperty(TYPE_THIS, type, constraint);
      builder.createStaticProperty(body, TYPE_CLASS, type, TYPE);
      state.addValue(TYPE_CLASS, value);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy