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

Examples of com.google.gwt.dev.jjs.ast.js.JsonObject


    }

    private JField createEnumValueMap(JEnumType type) {
      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,
          "enum$map".toCharArray(), type, map.getType(), true,
          Disposition.FINAL);

      // Initialize in clinit.
      JMethodBody clinitBody = (JMethodBody) type.getMethods().get(0).getBody();
      JExpressionStatement assignment = program.createAssignmentStmt(
View Full Code Here


    }

    private JField createEnumValueMap(JEnumType type) {
      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,
          "enum$map".toCharArray(), type, map.getType(), true,
          Disposition.FINAL);

      // Initialize in clinit.
      JMethodBody clinitBody = (JMethodBody) type.getMethods().get(0).getBody();
      JExpressionStatement assignment = program.createAssignmentStmt(
View Full Code Here

    private JsExpression generateTypeTable() {
      JsArrayLiteral arrayLit = new JsArrayLiteral(
          jsProgram.createSourceInfoSynthetic(GenerateJavaScriptAST.class,
              "Type table"));
      for (int i = 0; i < program.getJsonTypeTable().size(); ++i) {
        JsonObject jsonObject = program.getJsonTypeTable().get(i);
        accept(jsonObject);
        arrayLit.getExpressions().add((JsExpression) pop());
      }
      return arrayLit;
    }
View Full Code Here

    public void computeTypeIds() {

      // the 0th entry is the "always false" entry
      instantiableTypes.add(null);
      jsonObjects.add(new JsonObject(program.createSourceInfoSynthetic(
          AssignTypeIdsVisitor.class, "always-false typeinfo entry"),
          program.getJavaScriptObject()));

      /*
       * Do String first to reserve typeIds 1 and 2 for Object and String,
View Full Code Here

      }

      // Create a sparse lookup object.
      SourceInfo sourceInfo = program.createSourceInfoSynthetic(
          AssignTypeIdsVisitor.class, "typeinfo lookup");
      JsonObject jsonObject = new JsonObject(sourceInfo,
          program.getJavaScriptObject());
      // Start at 1; 0 is Object and always true.
      for (int i = 1; i < nextQueryId; ++i) {
        if (yesArray[i] != null) {
          JIntLiteral labelExpr = program.getLiteralInt(i);
View Full Code Here

    private void generateTypeTable(JsVars vars) {
      JField typeIdArray = program.getSpecialField("Cast.typeIdArray");
      JsName jsName = getName(typeIdArray);
      JsArrayLiteral arrayLit = new JsArrayLiteral();
      for (int i = 0; i < program.getJsonTypeTable().size(); ++i) {
        JsonObject jsonObject = (JsonObject) program.getJsonTypeTable().get(i);
        accept(jsonObject);
        arrayLit.getExpressions().add((JsExpression) pop());
      }
      JsVar var = new JsVar(jsName);
      var.setInitExpr(arrayLit);
View Full Code Here

    public void computeTypeIds() {

      // the 0th entry is the "always false" entry
      classes.add(null);
      jsonObjects.add(new JsonObject(program));

      /*
       * Compute the list of classes than can successfully satisfy cast
       * requests, along with the set of types they can be successfully cast to.
       * Do it in super type order.
View Full Code Here

          yesArray[boxedInt.intValue()] = yesType;
        }
      }

      // create a sparse lookup object
      JsonObject jsonObject = new JsonObject(program);
      for (int i = 0; i < nextQueryId; ++i) {
        if (yesArray[i] != null) {
          JIntLiteral labelExpr = program.getLiteralInt(i);
          JIntLiteral valueExpr = program.getLiteralInt(1);
          jsonObject.propInits.add(new JsonPropInit(program, labelExpr,
View Full Code Here

      return new JDeclarationStatement(program, info, new JLocalRef(program,
          info, local), value);
    }

    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);

      // Initialize in clinit.
      JMethodBody clinitBody = (JMethodBody) type.methods.get(0).getBody();
      JExpressionStatement assignment = program.createAssignmentStmt(null,
          createVariableRef(null, mapField), map);
View Full Code Here

    }

    private JsExpression generateTypeTable() {
      JsArrayLiteral arrayLit = new JsArrayLiteral();
      for (int i = 0; i < program.getJsonTypeTable().size(); ++i) {
        JsonObject jsonObject = program.getJsonTypeTable().get(i);
        accept(jsonObject);
        arrayLit.getExpressions().add((JsExpression) pop());
      }
      return arrayLit;
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.js.JsonObject

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.