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

org.snapscript.tree.reference.FunctionReference Maven / Gradle / Ivy

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

import org.snapscript.core.InternalStateException;
import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.function.Signature;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.type.Type;
import org.snapscript.tree.function.ParameterList;

public class FunctionReference extends ConstraintReference {
   
   private final ParameterList list;
   
   public FunctionReference(ParameterList list) {
      this.list = list;
   }
   
   @Override
   protected ConstraintValue create(Scope scope) {
      try {
         Signature signature = list.create(scope);
         Type type = signature.getDefinition();
         Constraint constraint = Constraint.getConstraint(type);
         
         return new ConstraintValue(type, constraint);
      } catch(Exception e) {
         throw new InternalStateException("Invalid function reference", e);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy