Example #1
0
  private static void declareMapMethod(
      final String methodSelector,
      final Type returnType,
      final List<String> paramNames,
      final List<Type> paramTypes) {
    final AccessQualifier Public = AccessQualifier.PublicAccess;

    final Iterator<Type> typeIterator = null == paramTypes ? null : paramTypes.iterator();
    final FormalParameterList formals = new FormalParameterList();
    if (null != paramNames) {
      for (final String paramName : paramNames) {
        if (null != paramName) {
          final Type paramType = typeIterator.next();
          final ObjectDeclaration formalParameter = new ObjectDeclaration(paramName, paramType, 0);
          formals.addFormalParameter(formalParameter);
        }
      }
    }
    final ObjectDeclaration self = new ObjectDeclaration("this", mapType_, 0);
    formals.addFormalParameter(self);
    StaticScope methodScope = new StaticScope(mapType_.enclosedScope());
    MethodDeclaration methodDecl =
        new MethodDeclaration(methodSelector, methodScope, returnType, Public, 0, false);
    methodDecl.addParameterList(formals);
    methodDecl.setReturnType(returnType);
    methodDecl.setHasConstModifier(false);
    mapType_.enclosedScope().declareMethod(methodDecl);
  }
Example #2
0
  private static void declareSetMethod(
      final String methodSelector,
      final Type returnType,
      final String paramName,
      final Type paramType,
      final boolean isConst) {
    final AccessQualifier Public = AccessQualifier.PublicAccess;

    final FormalParameterList formals = new FormalParameterList();
    if (null != paramName) {
      final ObjectDeclaration formalParameter = new ObjectDeclaration(paramName, paramType, 0);
      formals.addFormalParameter(formalParameter);
    }
    final ObjectDeclaration self = new ObjectDeclaration("this", listType_, 0);
    formals.addFormalParameter(self);
    StaticScope methodScope = new StaticScope(listType_.enclosedScope());
    final MethodDeclaration methodDecl =
        new MethodDeclaration(methodSelector, methodScope, returnType, Public, 0, false);
    methodDecl.addParameterList(formals);
    methodDecl.setReturnType(returnType);
    methodDecl.setHasConstModifier(isConst);
    listType_.enclosedScope().declareMethod(methodDecl);
  }