Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JParameter


    private JParameter createParameter(LocalVariableBinding binding,
        JMethod enclosingMethod) {
      JType type = (JType) typeMap.get(binding.type);
      SourceInfo info = makeSourceInfo(binding.declaration);
      JParameter param = program.createParameter(info, binding.name, type,
          binding.isFinal(), false, enclosingMethod);
      typeMap.put(binding, param);
      return param;
    }
View Full Code Here


    }

    private JParameter createParameter(SyntheticArgumentBinding arg,
        String argName, JMethod enclosingMethod) {
      JType type = (JType) typeMap.get(arg.type);
      JParameter param = program.createParameter(null, argName.toCharArray(),
          type, true, false, enclosingMethod);
      return param;
    }
View Full Code Here

      /*
       * If the type isn't static, make the first parameter a reference to the
       * instance of the enclosing class. It's the first instance to allow the
       * JSNI qualifier to be moved without affecting evaluation order.
       */
      JParameter enclosingInstance = null;
      if (!staticClass) {
        enclosingInstance = program.createParameter(null,
            "this$outer".toCharArray(), enclosingType, false, false, synthetic);
      }

      /*
       * In one pass, add the parameters to the synthetic constructor and
       * arguments to the method call.
       */
      for (Iterator<JParameter> i = constructor.params.iterator(); i.hasNext();) {
        JParameter param = i.next();
        /*
         * This supports x.new Inner() by passing the enclosing instance
         * implicitly as the last argument to the constructor.
         */
        if (enclosingInstance != null && !i.hasNext()) {
          args.add(new JParameterRef(program, null, enclosingInstance));
        } else {
          JParameter syntheticParam = program.createParameter(null,
              param.getName().toCharArray(), param.getType(), true, false,
              synthetic);
          args.add(new JParameterRef(program, null, syntheticParam));
        }
      }
View Full Code Here

      // name later when we generate the JavaScript during code generation.
      //
      String syntheticFnHeader = "function (";
      boolean first = true;
      for (int i = 0; i < newMethod.params.size(); ++i) {
        JParameter param = newMethod.params.get(i);
        if (first) {
          first = false;
        } else {
          syntheticFnHeader += ',';
        }
        syntheticFnHeader += param.getName();
      }
      syntheticFnHeader += ')';
      StringReader sr = new StringReader(syntheticFnHeader + '\n' + jsniCode);
      try {
        // start at -1 to avoid counting our synthetic header
View Full Code Here

      // All of the params in the target method are considered to be assigned by
      // the arguments from the caller
      Iterator<JExpression> argIt = x.getArgs().iterator();
      ArrayList<JParameter> params = x.getTarget().params;
      for (int i = 0; i < params.size(); ++i) {
        JParameter param = params.get(i);
        JExpression arg = argIt.next();
        if (param.getType() instanceof JReferenceType) {
          addAssignment(param, arg);
        }
      }
    }
View Full Code Here

        Set<JMethod> overrides = program.typeOracle.getAllOverrides(x);
        if (overrides.isEmpty()) {
          return true;
        }
        for (int j = 0, c = x.params.size(); j < c; ++j) {
          JParameter param = x.params.get(j);
          Set<JParameter> set = paramUpRefs.get(param);
          if (set == null) {
            set = new HashSet<JParameter>();
            paramUpRefs.put(param, set);
          }
          for (JMethod baseMethod : overrides) {
            JParameter baseParam = baseMethod.params.get(j);
            set.add(baseParam);
          }
        }
      } else if (program.isStaticImpl(x)) {
        /*
         * Special case: also add upRefs from a staticImpl's params to the
         * params of the instance method it is implementing. Most of the time,
         * this would happen naturally since the instance method delegates to
         * the static. However, in cases where the static has been inlined into
         * the instance method, future optimization could tighten an instance
         * call into a static call at some other call site, and fail to inline.
         * If we allowed a staticImpl param to be tighter than its instance
         * param, badness would ensue.
         */
        JMethod staticImplFor = program.staticImplFor(x);
        if (staticImplFor == null
            || !staticImplFor.getEnclosingType().methods.contains(staticImplFor)) {
          // The instance method has already been pruned.
          return true;
        }
        assert (x.params.size() == staticImplFor.params.size() + 1);
        for (int j = 0, c = x.params.size(); j < c; ++j) {
          JParameter param = x.params.get(j);
          Set<JParameter> set = paramUpRefs.get(param);
          if (set == null) {
            set = new HashSet<JParameter>();
            paramUpRefs.put(param, set);
          }
          if (j == 0) {
            // Fake an assignment-to-self to prevent tightening; consider this
            // an implicit assignment from a this reference of the looser type.
            assert (param.isThis());
            set.add(param);
          } else {
            JParameter baseParam = staticImplFor.params.get(j - 1);
            set.add(baseParam);
          }
        }
      }

View Full Code Here

            Iterator<JParameter> paramIt = getSyntheticsIterator();
            NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
            if (nestedBinding.enclosingInstances != null) {
              for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
                SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
                JParameter param = paramIt.next();
                if (arg.matchingField != null) {
                  JField field = (JField) typeMap.get(arg);
                  statements.add(program.createAssignmentStmt(info,
                      createVariableRef(info, field), createVariableRef(info,
                          param)));
                }
              }
            }

            if (nestedBinding.outerLocalVariables != null) {
              for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
                SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
                JParameter param = paramIt.next();
                JField field = (JField) typeMap.get(arg);
                statements.add(program.createAssignmentStmt(info,
                    createVariableRef(info, field), createVariableRef(info,
                        param)));
              }
View Full Code Here

        outer : for (int j = 0; j < javaLangString.methods.size(); ++j) {
          JMethod method = javaLangString.methods.get(j);
          if (method.getName().equals("_String")
              && method.params.size() == ctorArgc) {
            for (int i = 0; i < ctorArgc; ++i) {
              JParameter mparam = method.params.get(i);
              JParameter cparam = ctor.params.get(i);
              if (mparam.getType() != cparam.getType()) {
                continue outer;
              }
            }
            targetMethod = method;
            break;
View Full Code Here

        if (superBinding.syntheticOuterLocalVariables() != null) {
          for (SyntheticArgumentBinding arg : superBinding.syntheticOuterLocalVariables()) {
            // Got to be one of my params
            JType varType = (JType) typeMap.get(arg.type);
            String varName = String.valueOf(arg.name);
            JParameter param = null;
            for (int i = 0; i < currentMethod.params.size(); ++i) {
              JParameter paramIt = currentMethod.params.get(i);
              if (varType == paramIt.getType()
                  && varName.equals(paramIt.getName())) {
                param = paramIt;
              }
            }
            if (param == null) {
              throw new InternalCompilerException(
View Full Code Here

          throw new InternalCompilerException(
              "LocalRef referencing local in a different method.");
        }
        return new JLocalRef(program, info, local);
      } else if (variable instanceof JParameter) {
        JParameter parameter = (JParameter) variable;
        if (parameter.getEnclosingMethod() != currentMethod) {
          throw new InternalCompilerException(
              "ParameterRef referencing param in a different method.");
        }
        return new JParameterRef(program, info, parameter);
      } else if (variable instanceof JField) {
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JParameter

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.