Esempio n. 1
0
 public MethodSupport(
     ScopeLookup scope, ASTMethod node, Set<? extends Modifier> modifiers, LpcType returnType) {
   _node = node;
   ASTIdentifier identifier = ASTUtil.getChild(ASTIdentifier.class, _node);
   Token token = identifier.jjtGetFirstToken();
   _name = token.image;
   _body = ASTUtil.getChild(ASTStatementBlock.class, node);
   _scope = scope;
   _modifiers = modifiers;
   _returnType = returnType;
   _namer = new MethodNamer(true, false);
   _argumentDefinitions = buildArgumentDefinitions();
 }
Esempio n. 2
0
 public static List<? extends ArgumentDefinition> buildArgumentDefinitions(
     ASTParameterDeclarations parameters, ScopeLookup scope) {
   List<ArgumentDefinition> args =
       new ArrayList<ArgumentDefinition>(parameters.jjtGetNumChildren());
   for (TokenNode child : ASTUtil.children(parameters)) {
     assert child instanceof ASTParameterDeclaration;
     args.add(buildArgumentDefinition((ASTParameterDeclaration) child, scope));
   }
   return args;
 }
Esempio n. 3
0
  private static ArgumentDefinition buildArgumentDefinition(
      ASTParameterDeclaration node, ScopeLookup scope) {
    ASTFullType fullType = ASTUtil.getChild(ASTFullType.class, node);
    ASTIdentifier identifier = ASTUtil.getChild(ASTIdentifier.class, node);
    boolean ref = ASTUtil.hasChildType(ASTRef.class, node);
    boolean expander = ASTUtil.hasChildType(ASTElementExpander.class, node);

    String name = ASTUtil.getImage(identifier);

    LpcType type = new TypeSupport(scope, fullType).getType();
    if (expander && !type.isArray()) {
      throw new CompileException(
          node,
          "Attempt to use expander (vargargs) '...' on argument '"
              + name
              + "' without declaring it as an array");
    }
    return new ArgumentSpec(
        name,
        type,
        expander,
        ref ? ArgumentSemantics.EXPLICIT_REFERENCE : ArgumentSemantics.BY_VALUE);
  }
Esempio n. 4
0
 public String getIdentifierName() {
   return ASTUtil.getImage(this);
 }
Esempio n. 5
0
 private List<? extends ArgumentDefinition> buildArgumentDefinitions() {
   ASTParameterDeclarations parameters = ASTUtil.getChild(ASTParameterDeclarations.class, _node);
   return buildArgumentDefinitions(parameters, _scope);
 }