Пример #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();
 }
Пример #2
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);
  }
Пример #3
0
 private List<? extends ArgumentDefinition> buildArgumentDefinitions() {
   ASTParameterDeclarations parameters = ASTUtil.getChild(ASTParameterDeclarations.class, _node);
   return buildArgumentDefinitions(parameters, _scope);
 }