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

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

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

import org.snapscript.core.Evaluation;
import org.snapscript.core.Result;
import org.snapscript.core.Scope;
import org.snapscript.core.Type;
import org.snapscript.core.TypeFactory;
import org.snapscript.core.Value;

public class SuperFactory extends TypeFactory {
   
   private final SuperInstanceBuilder builder;
   private final Evaluation expression;
   
   public SuperFactory(Evaluation expression, Type type) {
      this.builder = new SuperInstanceBuilder(type);
      this.expression = expression;
   }
   
   @Override
   public Result compile(Scope instance, Type real) throws Exception {
      expression.compile(instance);
      return Result.getNormal();
   }

   @Override
   public Result execute(Scope instance, Type real) throws Exception {
      Value reference = expression.evaluate(instance, real); 
      Scope value = reference.getValue();
      Scope base = builder.create(value, real);
      
      return Result.getNormal(base);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy