Examples of JStringLiteral


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

      SourceInfo sourceInfo = type.getSourceInfo().makeChild(
          JavaASTGenerationVisitor.class, "enum value lookup map");
      JsonObject map = new JsonObject(sourceInfo, program.getJavaScriptObject());
      for (JEnumField field : type.getEnumList()) {
        // JSON maps require leading underscores to prevent collisions.
        JStringLiteral key = program.getLiteralString(field.getSourceInfo(),
            "_" + field.getName());
        JFieldRef value = new JFieldRef(sourceInfo, null, field, type);
        map.propInits.add(new JsonObject.JsonPropInit(sourceInfo, key, value));
      }
      JField mapField = program.createField(sourceInfo,
View Full Code Here

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

      SourceInfo sourceInfo = type.getSourceInfo().makeChild(
          JavaASTGenerationVisitor.class, "enum value lookup map");
      JsonObject map = new JsonObject(sourceInfo, program.getJavaScriptObject());
      for (JEnumField field : type.getEnumList()) {
        // JSON maps require leading underscores to prevent collisions.
        JStringLiteral key = program.getLiteralString(field.getSourceInfo(),
            "_" + field.getName());
        JFieldRef value = new JFieldRef(sourceInfo, null, field, type);
        map.propInits.add(new JsonObject.JsonPropInit(sourceInfo, key, value));
      }
      JField mapField = program.createField(sourceInfo,
View Full Code Here

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

    private JField createEnumValueMap(JEnumType type) {
      JsonObject map = new JsonObject(program);
      for (JEnumField field : type.enumList) {
        // JSON maps require leading underscores to prevent collisions.
        JStringLiteral key = program.getLiteralString("_" + field.getName());
        JFieldRef value = new JFieldRef(program, null, null, field, type);
        map.propInits.add(new JsonObject.JsonPropInit(program, key, value));
      }
      JField mapField = program.createField(null, "enum$map".toCharArray(),
          type, map.getType(), true, Disposition.FINAL);
View Full Code Here

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

      }
      return jlabel;
    }

    private JStringLiteral getStringLiteral(SourceInfo info, char[] chars) {
      return new JStringLiteral(info, intern(chars), javaLangString);
    }
View Full Code Here

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

    private JStringLiteral getStringLiteral(SourceInfo info, char[] chars) {
      return new JStringLiteral(info, intern(chars), javaLangString);
    }

    private JStringLiteral getStringLiteral(SourceInfo info, String string) {
      return new JStringLiteral(info, intern(string), javaLangString);
    }
View Full Code Here

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

      JExpression arg = x.getArgs().get(0);
      if (!(arg instanceof JStringLiteral)) {
        error(x, "Only string literals may be used as arguments to Impl.getNameOf()");
        return null;
      }
      JStringLiteral stringLiteral = (JStringLiteral) arg;
      String stringValue = stringLiteral.getValue();
      JNode node = null;

      JsniRef ref = JsniRef.parse(stringValue);
      if (ref != null) {
        node = JsniRefLookup.findJsniRefTarget(ref, program, new JsniRefLookup.ErrorReporter() {
View Full Code Here

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

    }

    assert method != null;

    JMethodCall call = new JMethodCall(info, null, method);
    JStringLiteral packageName = program.getLiteralString(info, getPackageName(typeName));
    JStringLiteral className = program.getLiteralString(info, getClassName(typeName));
    call.addArgs(packageName, className);

    if (type instanceof JArrayType) {
      // There's only one seed function for all arrays
      JDeclaredType arrayType = program.getIndexedType("Array");
      call.addArg(new JNameOf(info, className.getType(), arrayType));

    } else if (type instanceof JClassType) {
      // Add the name of the seed function for concrete types
      call.addArg(new JNameOf(info, className.getType(), type));

    } else if (type instanceof JPrimitiveType) {
      // And give primitive types an illegal, though meaningful, value
      call.addArg(program.getLiteralString(info, " " + type.getJavahSignatureName()));
    }
View Full Code Here

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

      }
      return jlabel;
    }

    private JStringLiteral getStringLiteral(SourceInfo info, char[] chars) {
      return new JStringLiteral(info, intern(chars), javaLangString);
    }
View Full Code Here

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

    private JStringLiteral getStringLiteral(SourceInfo info, char[] chars) {
      return new JStringLiteral(info, intern(chars), javaLangString);
    }

    private JStringLiteral getStringLiteral(SourceInfo info, String string) {
      return new JStringLiteral(info, intern(string), javaLangString);
    }
View Full Code Here

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

    }

    private void replaceImplNameOf(JMethodCall x, Context ctx) {
      JExpression arg0 = x.getArgs().get(0);
      assert arg0 instanceof JStringLiteral;
      JStringLiteral stringLiteral = (JStringLiteral) arg0;
      String stringValue = stringLiteral.getValue();

      HasName named = null;

      JDeclaredType refType;
      JsniRef ref = JsniRef.parse(stringValue);

      if (ref != null) {
        final List<String> errors = new ArrayList<String>();
        JNode node = JsniRefLookup.findJsniRefTarget(ref, program,
            new JsniRefLookup.ErrorReporter() {
              public void reportError(String error) {
                errors.add(error);
              }
            });

        if (!errors.isEmpty()) {
          for (String error : errors) {
            logger.log(TreeLogger.ERROR, error);
          }
        }

        if (node instanceof HasName) {
          named = (HasName) node;
        }

      } else {
        // See if it's just @foo.Bar, which would result in the class seed
        refType = program.getFromTypeMap(stringValue.charAt(0) == '@'
            ? stringValue.substring(1) : stringValue);
        if (refType != null) {
          named = refType;
        }
      }

      if (named == null) {
        // Not found, must be null
        ctx.replaceMe(JNullLiteral.INSTANCE);
      } else {
        ctx.replaceMe(new JNameOf(x.getSourceInfo(), stringLiteral.getType(),
            named));
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.