Examples of ConstructorFunction


Examples of org.rascalmpl.interpreter.result.ConstructorFunction

      }
    }

    if (type.hasKeywordParameters()) {
      // this fills in the defaults for pattern matching against them:
      ConstructorFunction func = ctx.getCurrentEnvt().getConstructorFunction(type);
      Map<String, IValue> kwArgs = func.computeKeywordArgs(subjectChildren, subject.getValue().asWithKeywordParameters().getParameters());

     
      for (String kwLabel : type.getKeywordParameterTypes().getFieldNames()) {
        IValue subjectParam = kwArgs.get(kwLabel);
       
        if (keywordParameters.containsKey(kwLabel)) {
          IMatchingResult matcher = keywordParameters.get(kwLabel);
          matcher.initMatch(ResultFactory.makeResult(type.getKeywordParameterType(kwLabel), subjectParam, ctx));
         
          if (!matcher.hasNext()) {
            // the matcher can never work, so we can skip initializing the rest
            hasNext = false;
            break;
          }
        }
       
        // note if there is no matcher for the current parameter, still we have initialized it because the next
        // keyword parameter that who do match on may depend on its dynamic value.
      }
    }
    else if (this.subject.mayHaveKeywordParameters()) {
      Map<String, IValue> kwArgs;
     
      // the matching side has no declared keyword parameters (an untyped node), so we do not have default values to take care of
      if (this.subject.getType().isAbstractData()) {
        ConstructorFunction func = ctx.getCurrentEnvt().getConstructorFunction(((IConstructor) this.subject).getConstructorType());
     
        if (func != null) {
          kwArgs = func.computeKeywordArgs(subjectChildren, subject.getValue().asWithKeywordParameters().getParameters());
        }
        else {
          // the definition of the constructor could not be found, so we don't have defaults
          kwArgs = this.subject.asWithKeywordParameters().getParameters();
        }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ConstructorFunction

    List<AbstractFunction> list = new LinkedList<>();
    getAllFunctions(constructorType.getAbstractDataType(), constructorType.getName(), list);
   
    for (AbstractFunction candidate : list) {
      if (candidate instanceof ConstructorFunction) {
        ConstructorFunction func = (ConstructorFunction) candidate;
       
        if (func.getName().equals(constructorType.getName())
            && func.getFunctionType() == functionType) {
          return func;
        }
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.