Package org.rascalmpl.interpreter.result

Examples of org.rascalmpl.interpreter.result.AbstractFunction


      if (!hasJavaModifier(this)) {
        throw new MissingModifier("java", this);
      }

      AbstractFunction lambda = new JavaMethod(__eval, this, varArgs,
          __eval.getCurrentEnvt(), __eval.__getJavaBridge());
      String name = org.rascalmpl.interpreter.utils.Names.name(this
          .getSignature().getName());
   
      __eval.getCurrentEnvt().storeFunction(name, lambda);
      __eval.getCurrentEnvt().markNameFinal(lambda.getName());
      __eval.getCurrentEnvt().markNameOverloadable(lambda.getName());

      lambda.setPublic(this.getVisibility().isPublic() || this.getVisibility().isDefault());
      return lambda;

    }
View Full Code Here


      super(__param1, __param2, __param3, __param4, __param5);
    }

    @Override
    public Result<IValue> interpret(IEvaluator<Result<IValue>> __eval) {
      AbstractFunction lambda;
      boolean varArgs = this.getSignature().getParameters().isVarArgs();

      if (hasJavaModifier(this)) {
        throw new NonAbstractJavaFunction(this);
      }

      if (!this.getBody().isDefault()) {
        throw new MissingModifier("java", this);
      }

      lambda = new RascalFunction(__eval, this, varArgs, __eval
          .getCurrentEnvt(), __eval.__getAccumulators());

      __eval.getCurrentEnvt().storeFunction(lambda.getName(), lambda);
      __eval.getCurrentEnvt().markNameFinal(lambda.getName());
      __eval.getCurrentEnvt().markNameOverloadable(lambda.getName());

      lambda.setPublic(this.getVisibility().isPublic() || this.getVisibility().isDefault());
      return lambda;

    }
View Full Code Here

    public Result<IValue> interpret(IEvaluator<Result<IValue>> __eval) {
     
      __eval.setCurrentAST(this);
      __eval.notifyAboutSuspension(this);     
     
      AbstractFunction lambda;
      boolean varArgs = this.getSignature().getParameters().isVarArgs();

      if (hasJavaModifier(this)) {
        throw new NonAbstractJavaFunction(this);
      }

      lambda = new RascalFunction(__eval, this, varArgs, __eval
          .getCurrentEnvt(), __eval.__getAccumulators());
     
   
      lambda.setPublic(this.getVisibility().isPublic() || this.getVisibility().isDefault());
      __eval.getCurrentEnvt().markNameFinal(lambda.getName());
      __eval.getCurrentEnvt().markNameOverloadable(lambda.getName());
     
      __eval.getCurrentEnvt().storeFunction(lambda.getName(), lambda);
     
      return lambda;
    }
View Full Code Here

    public Result<IValue> interpret(IEvaluator<Result<IValue>> __eval) {
         
      __eval.setCurrentAST(this);
      __eval.notifyAboutSuspension(this)
     
      AbstractFunction lambda;
      boolean varArgs = this.getSignature().getParameters().isVarArgs();

      if (hasJavaModifier(this)) {
        throw new NonAbstractJavaFunction(this);
      }

      ISourceLocation src = this.getLocation();
      AbstractAST ret = ASTBuilder.makeStat("Return", src, ASTBuilder.makeStat("Expression", src, getExpression()));
      AbstractAST fail = ASTBuilder.makeStat("Fail", src, ASTBuilder.make("Target", "Labeled", src, getSignature().getName()));
      AbstractAST ite = ASTBuilder.makeStat("IfThenElse", src, ASTBuilder.make("Label", "Empty", src), getConditions(), ret, fail);
      List<AbstractAST> sl = Arrays.<AbstractAST>asList(ite);
      AbstractAST body = ASTBuilder.make("FunctionBody", "Default", src, sl);
      FunctionDeclaration.Default func = ASTBuilder.make("FunctionDeclaration", "Default", src, getTags(), getVisibility(), getSignature(), body);
     
      lambda = new RascalFunction(__eval, func, varArgs, __eval
          .getCurrentEnvt(), __eval.__getAccumulators());

      __eval.getCurrentEnvt().storeFunction(lambda.getName(), lambda);
      __eval.getCurrentEnvt().markNameFinal(lambda.getName());
      __eval.getCurrentEnvt().markNameOverloadable(lambda.getName());

      lambda.setPublic(this.getVisibility().isPublic() || this.getVisibility().isDefault());
      return lambda;
    }
View Full Code Here

     
      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

  private void runTests(ModuleEnvironment env, List<AbstractFunction> tests) {
    testResultListener.start(tests.size());

//    try {
    for (int i = tests.size() - 1; i >= 0; i--) {
      AbstractFunction test = tests.get(i);
      if (test.hasTag("ignore") || test.hasTag("Ignore") || test.hasTag("ignoreInterpreter") || test.hasTag("IgnoreInterpreter")) {
        continue;
      }

      try{
        QuickCheck qc = QuickCheck.getInstance();
        StringWriter sw = new StringWriter();
        PrintWriter out = new PrintWriter(sw);
        int maxDepth = Cobra.readIntTag(test, Cobra.MAXDEPTH, 5);
        int tries = Cobra.readIntTag(test, Cobra.TRIES, 500);

        boolean result = qc.quickcheck(test, maxDepth, tries, false, out);
        if (!result) {
          out.flush();
          testResultListener.report(false, test.getName(), test.getAst().getLocation(), sw.getBuffer()
              .toString(), null);
        } else {
          testResultListener.report(true, test.getName(), test.getAst().getLocation(), sw.getBuffer()
              .toString(), null);
        }
      }
      catch(StaticError e) {
        testResultListener.report(false, test.getName(), test.getAst().getLocation(), e.getMessage(), e);
      }
      catch(Throw e){
        testResultListener.report(false, test.getName(), test.getAst().getLocation(), e.getMessage(), e);
      }
      catch(Throwable e){
        testResultListener.report(false, test.getName(), test.getAst().getLocation(), e.getMessage(), e);
      }
    }
    //    }
    //    finally {
    testResultListener.done();
View Full Code Here

    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

TOP

Related Classes of org.rascalmpl.interpreter.result.AbstractFunction

Copyright © 2018 www.massapicom. 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.