Package loop.ast.script

Examples of loop.ast.script.FunctionDecl.arguments()


  }

  public Object main(String[] commandLine) {
    FunctionDecl main = scope.resolveFunction("main", false);
    if (main != null) {
      int args = main.arguments().children().size();
      if(commandLine == null)
        commandLine = new String[] {};
      try {
        if (args == 0)
          return compiled.getDeclaredMethod("main").invoke(null);
View Full Code Here


    FunctionDecl exceptionHandler = resolveCall(functionDecl.exceptionHandler);
    if (exceptionHandler == null)
      addError("Cannot resolve exception handler: " + functionDecl.exceptionHandler,
          functionDecl.sourceLine, functionDecl.sourceColumn);
    else {
      int argsSize = exceptionHandler.arguments().children().size();
      // Verify exception handler template.
      if (!exceptionHandler.patternMatching)
        addError("Exception handler must be a pattern-matching function (did you mean '=>')",
            exceptionHandler.sourceLine, exceptionHandler.sourceColumn);
      else if (argsSize != 1) {
View Full Code Here

      FunctionDecl targetFunction = resolveCall(call.name);
      if (targetFunction == null)
        addError("Cannot resolve function: " + call.name, call.sourceLine, call.sourceColumn);
      else {
        // Check that the args are correct.
        int targetArgs = targetFunction.arguments().children().size();
        int calledArgs = call.args().children().size();
        if (calledArgs != targetArgs)
          addError("Incorrect number of arguments to: " + targetFunction.name()
              + " (expected " + targetArgs + ", found "
              + calledArgs + ")",
View Full Code Here

      PatternRule patternRule = (PatternRule) node;
      verifyNode(patternRule.rhs);

      // Some sanity checking of pattern rules.
      FunctionDecl function = functionStack.peek().function;
      int argsSize = function.arguments().children().size();
      int patternsSize = patternRule.patterns.size();
      if (patternsSize != argsSize)
        addError("Incorrect number of patterns in: '" + function.name() + "' (expected " + argsSize
            + " found " + patternsSize + ")", patternRule.sourceLine, patternRule.sourceColumn);
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.