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

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


    }

    private JExpression maybeCast(JType expected, JExpression expression) {
      if (expected != expression.getType()) {
        // Must be a generic; insert a cast operation.
        JReferenceType toType = (JReferenceType) expected;
        return new JCastOperation(program, expression.getSourceInfo(), toType,
            expression);
      } else {
        return expression;
      }
View Full Code Here


              "Badly formatted native reference '" + ident + "'");
          return null;
        }

        String className = parsed.className();
        JReferenceType type = null;
        if (!className.equals("null")) {
          type = program.getFromTypeMap(className);
          if (type == null) {
            reportJsniError(info, methodDecl,
                "Unresolvable native reference to type '" + className + "'");
            return null;
          }
        }

        if (!parsed.isMethod()) {
          // look for a field
          String fieldName = parsed.memberName();
          if (type == null) {
            if (fieldName.equals("nullField")) {
              return program.getNullField();
            }
          } else {
            for (int i = 0; i < type.fields.size(); ++i) {
              JField field = type.fields.get(i);
              if (field.getName().equals(fieldName)) {
                return field;
              }
            }
          }

          reportJsniError(info, methodDecl,
              "Unresolvable native reference to field '" + fieldName
                  + "' in type '" + className + "'");
          return null;
        } else {
          // look for a method
          TreeSet<String> almostMatches = new TreeSet<String>();
          String methodName = parsed.memberName();
          String jsniSig = parsed.memberSignature();
          if (type == null) {
            if (jsniSig.equals("nullMethod()")) {
              return program.getNullMethod();
            }
          } else {
            Queue<JReferenceType> workList = new LinkedList<JReferenceType>();
            workList.add(type);
            while (!workList.isEmpty()) {
              JReferenceType cur = workList.poll();
              for (int i = 0; i < cur.methods.size(); ++i) {
                JMethod method = cur.methods.get(i);
                if (method.getName().equals(methodName)) {
                  String sig = JProgram.getJsniSig(method);
                  if (sig.equals(jsniSig)) {
View Full Code Here

        nativeMethodBody.jsniFieldRefs.add(fieldRef);
      }

      private void processMethod(JsNameRef nameRef, SourceInfo info,
          JMethod method, JsContext<JsExpression> ctx) {
        JReferenceType enclosingType = method.getEnclosingType();
        if (enclosingType != null) {
          if (method.isStatic() && nameRef.getQualifier() != null) {
            reportJsniError(info, methodDecl,
                "Cannot make a qualified reference to the static method "
                    + method.getName());
          } else if (!method.isStatic() && nameRef.getQualifier() == null) {
            reportJsniError(info, methodDecl,
                "Cannot make an unqualified reference to the instance method "
                    + method.getName());
          } else if (!method.isStatic()
              && program.isJavaScriptObject(enclosingType)) {
            reportJsniError(
                info,
                methodDecl,
                "Illegal reference to instance method '"
                    + method.getName()
                    + "' in type '"
                    + enclosingType.getName()
                    + "', which is an overlay type; only static references to overlay types are allowed from JSNI");
          }
        }
        if (ctx.isLvalue()) {
          reportJsniError(info, methodDecl, "Cannot reassign the Java method "
View Full Code Here

      currentMethod = x;
      return true;
    }

    private JMethodCall createClinitCall(JMethodCall x) {
      JReferenceType targetEnclosingType = x.getTarget().getEnclosingType();
      if (!program.typeOracle.checkClinit(currentMethod.getEnclosingType(),
          targetEnclosingType)) {
        // Access from this class to the target class won't trigger a clinit
        return null;
      }
View Full Code Here

    private JsInvocation maybeCreateClinitCall(JField x) {
      if (!x.isStatic()) {
        return null;
      }

      JReferenceType enclosingType = x.getEnclosingType();
      if (!typeOracle.checkClinit(currentMethod.getEnclosingType(),
          enclosingType)) {
        return null;
      }
View Full Code Here

        return null;
      }
      if (!x.isStatic() || program.isStaticImpl(x)) {
        return null;
      }
      JReferenceType enclosingType = x.getEnclosingType();
      if (!typeOracle.hasClinit(enclosingType)) {
        return null;
      }
      // avoid recursion sickness
      if (x == enclosingType.methods.get(0)) {
View Full Code Here

        // Now let's implicitly create a static function called 'new' that will
        // allow construction from JSNI methods
        if (!enclosingType.isAbstract()) {
          ReferenceBinding enclosingBinding = ctorDecl.binding.declaringClass.enclosingType();
          JReferenceType outerType = enclosingBinding == null ? null
              : (JReferenceType) typeMap.get(enclosingBinding);
          createSyntheticConstructor(newMethod,
              ctorDecl.binding.declaringClass.isStatic(), outerType);
        }
View Full Code Here

    @Override
    public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
      try {
        FieldBinding b = fieldDeclaration.binding;
        SourceInfo info = makeSourceInfo(fieldDeclaration);
        JReferenceType enclosingType = (JReferenceType) typeMap.get(scope.enclosingSourceType());
        Expression initialization = fieldDeclaration.initialization;
        if (initialization != null
            && initialization instanceof AllocationExpression
            && ((AllocationExpression) initialization).enumConstant != null) {
          createEnumField(info, b, enclosingType);
View Full Code Here

    @Override
    public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
      try {
        MethodBinding b = methodDeclaration.binding;
        SourceInfo info = makeSourceInfo(methodDeclaration);
        JReferenceType enclosingType = (JReferenceType) typeMap.get(scope.enclosingSourceType());
        JMethod newMethod = processMethodBinding(b, enclosingType, info);
        mapParameters(newMethod, methodDeclaration);

        if (newMethod.isNative()) {
          processNativeMethod(methodDeclaration, info, enclosingType, newMethod);
View Full Code Here

    private JMethodBody findEnclosingMethod(BlockScope scope) {
      JMethod method;
      MethodScope methodScope = scope.methodScope();
      if (methodScope.isInsideInitializer()) {
        JReferenceType enclosingType = (JReferenceType) typeMap.get(scope.classScope().referenceContext.binding);
        if (methodScope.isStatic) {
          // clinit
          method = enclosingType.methods.get(0);
        } else {
          // init
View Full Code Here

TOP

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

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.