Examples of OverloadedFunction


Examples of org.rascalmpl.interpreter.result.OverloadedFunction

     
      if (result.isEmpty()) {
        return null;
      }
     
      return new OverloadedFunction(cons, result);
    }
   
    if (modulename != null) {
      if (modulename.equals(getName())) {
        return getVariable(cons);
View Full Code Here

Examples of org.rascalmpl.interpreter.result.OverloadedFunction

    try {
      ModuleEnvironment modEnv = getHeap().getModule(module);
      setCurrentEnvt(modEnv);
     
      Name name = Names.toName(function, modEnv.getLocation());
      OverloadedFunction func = (OverloadedFunction) getCurrentEnvt().getVariable(name);
     
      if (func == null) {
        throw new UndeclaredVariable(function, name);
      }
     
      AbstractFunction main = func.getFunctions().get(0);
     
      if (func.getFunctions().size() > 1) {
        throw new CommandlineError("should only have one main function", main);
      }
     
      if (main.getArity() == 1) {
        return func.call(getMonitor(), new Type[] { tf.listType(tf.stringType()) },new IValue[] { parsePlainCommandLineArgs(commandline)}, null).getValue();
      }
      else if (main.hasKeywordArgs() && main.getArity() == 0) {
        Map<String, IValue> args = parseKeywordCommandLineArgs(monitor, commandline, main);
        return func.call(getMonitor(), new Type[] { },new IValue[] {}, args).getValue();
      }
      else {
        throw new CommandlineError("main function should either have one argument of type list[str], or keyword parameters", main);
      }
    }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.OverloadedFunction

    setCurrentAST(qualifiedName);
    return call(qualifiedName, kwArgs, args);
  }
 
  public IValue call(QualifiedName qualifiedName, Map<String,IValue> kwArgs, IValue... args) {
    OverloadedFunction func = (OverloadedFunction) getCurrentEnvt().getVariable(qualifiedName);
    RascalTypeFactory rtf = RascalTypeFactory.getInstance();
   
    Type[] types = new Type[args.length];

    int i = 0;
    for (IValue v : args) {
      Type type = v.getType();
      types[i++] = type.isSubtypeOf(Factory.Tree) ? rtf.nonTerminalType((IConstructor) v) : type;
    }
   
    if (func == null) {
      throw new UndeclaredFunction(Names.fullName(qualifiedName), types, this, getCurrentAST());
    }

    return func.call(getMonitor(), types, args, kwArgs).getValue();
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.OverloadedFunction

    super(computeMessage(function, argTypes), caller);
  }

  private static String computeMessage(Result<IValue> function, Type[] argTypes) {
    if (function instanceof OverloadedFunction) {
      OverloadedFunction of = (OverloadedFunction) function;
      return computeMessage(of.getName(), of.getFunctions(), argTypes);
    }
    else {
      AbstractFunction func = (AbstractFunction) function;
      return computeMessage(func.getName(), Arrays.<AbstractFunction>asList(func), argTypes);
    }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.OverloadedFunction

    getAllFunctions(name, funcs);
   
    if (funcs.isEmpty()) {
      return null;
    }
    return new OverloadedFunction(name, funcs);
  }
View Full Code Here

Examples of xbird.xquery.operator.OverloadedFunction

    }

    @Override
    public XQExpression staticAnalysis(StaticContext statEnv) throws XQueryException {
        super.staticAnalysis(statEnv);
        OverloadedFunction op = resolveOp();
        op.staticAnalysis(statEnv, _leftOperand, _rightOperand);
        this._op = op;
        this._type = op.getReturnType();
        return this;
    }
View Full Code Here

Examples of xbird.xquery.operator.OverloadedFunction

    }

    @Override
    public XQExpression staticAnalysis(StaticContext statEnv) throws XQueryException {
        super.staticAnalysis(statEnv);
        final OverloadedFunction op = resolveOp();
        op.staticAnalysis(statEnv, _leftOperand, _rightOperand);
        this._op = op;
        if(_leftOperand instanceof Evaluable && _rightOperand instanceof Evaluable) {
            // apply eagar evaluation
            final Sequence<? extends Item> evaluated = eval(null, DynamicContext.DUMMY);
            return new PreEvaluatedVariable(evaluated);
        }
        this._type = op.getReturnType();
        return this;
    }
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.