Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.IntegerLiteral


  private static boolean isExpressionListTerminator(ParseTreeNode s) {
    return s instanceof ReturnStmt || s instanceof ThrowStmt;
  }

  private static Expression undef(FilePosition pos) {
    return Operation.create(pos, Operator.VOID, new IntegerLiteral(pos, 0));
  }
View Full Code Here


    for (U e : entries) {
      // Since enum values are public, we don't want Closure compiler
      // to rewrite them, so we need quoted keys.
      String quoted = StringLiteral.toQuotedValue(keyMaker.apply(e));
      keys.add(new StringLiteral(unk, quoted));
      values.add(new IntegerLiteral(unk, valueMaker.apply(e)));
    }
    return new ExpressionStmt(unk,
        (Expression) QuasiBuilder.substV(
            "html4.@i = { @k*: @v* };",
            "i", new Reference(new Identifier(unk, key)),
View Full Code Here

        if (ElKey.HTML_WILDCARD.equals(key.el)
            || schema.isElementAllowed(key.el)
            // Whitelisted to allow dynamic script loading via proxy
            || SCRIPT_SRC.equals(key)) {
          keys.add(StringLiteral.valueOf(unk, key.toString()));
          values.add(new IntegerLiteral(unk, A_TYPE_MAP.get(e.getValue())));
        }
      }
      definitions.appendChild(new ExpressionStmt(unk, (Expression)
          QuasiBuilder.substV(
              "html4.ATTRIBS = { @k*: @v* };",
              "k", new ParseTreeNodeContainer(keys),
              "v", new ParseTreeNodeContainer(values))));
    }

    definitions.appendChild(mapFromEnum(
        EnumSet.allOf(EFlag.class),
        "eflags",
        new Function<EFlag, String>() {
          public String apply(EFlag f) {
            return f.name();
          }
        },
        new Function<EFlag, Integer>() {
          public Integer apply(EFlag f) {
            return f.bitMask;
          }
        })
    );

    {
      List<StringLiteral> keys = new ArrayList<StringLiteral>();
      List<IntegerLiteral> values = new ArrayList<IntegerLiteral>();
      for (Map.Entry<ElKey, EnumSet<EFlag>> e : eflags.entrySet()) {
        ElKey key = e.getKey();
        int value = 0;
        for (EFlag f : e.getValue()) { value |= f.bitMask; }
        keys.add(StringLiteral.valueOf(unk, key.toString()));
        values.add(new IntegerLiteral(unk, value));
      }
      definitions.appendChild(new ExpressionStmt(unk, (Expression)
          QuasiBuilder.substV(
              "html4.ELEMENTS = { @k*: @v* };",
              "k", new ParseTreeNodeContainer(keys),
View Full Code Here

    Number n = rl.getValue();
    double dv = n.doubleValue();
    long lv = n.longValue();
    // Convert 1.0 to 1, but do not convert -0.0 to 0.
    if (dv == lv && (dv != 0d || (1 / dv) > 0)) {
      return new IntegerLiteral(rl.getFilePosition(), lv);
    }
    return rl;
  }
View Full Code Here

      if (regex != null) {
        int poolIndex = regexPoolMap.get(regex)[0];
        Expression re = poolIndex < 0
            ? makeRegexp(commonSubstringMap, regex)
            : (Expression) QuasiBuilder.substV(
                "c[@i]", "i", new IntegerLiteral(unk, poolIndex));
        dataObj.appendChild(new ValueProperty(regexObjKey, re));
      }

      String dom2property = propertyNameToDom2Property(prop.name);
      ArrayConstructor altNames = null;
      for (String altDom2Property : prop.dom2properties) {
        if (altDom2Property.equals(dom2property)) { continue; }
        if (altNames == null) {
          altNames = new ArrayConstructor(
              unk, Collections.<Expression>emptyList());
        }
        altNames.appendChild(StringLiteral.valueOf(unk, altDom2Property));
      }
      if (altNames != null) {
        dataObj.appendChild(new ValueProperty(alternatesObjKey, altNames));
      }

      cssSchemaProps.add(new ValueProperty(
          unk, StringLiteral.valueOf(unk, prop.name.getCanonicalForm()),
          dataObj));

      int propBits = 0;
      for (CssPropBit b : data.properties) {
        propBits |= b.jsValue;
      }
      if (LinkStyleWhitelist.HISTORY_INSENSITIVE_STYLE_WHITELIST
          .contains(prop.name)) {
        propBits |= CssPropBit.HISTORY_INSENSITIVE.jsValue;
      } else if (LinkStyleWhitelist.PROPERTIES_ALLOWED_IN_LINK_CLASSES
                 .contains(prop.name)) {
        propBits |= CssPropBit.ALLOWED_IN_LINK.jsValue;
      }
      dataObj.appendChild(
          new ValueProperty(propbitsObjKey, new IntegerLiteral(unk, propBits)));

      List<Expression> litGroups = Lists.newArrayList();
      for (int groupIndex : litPartition.unions[propIndex]) {
        litGroups.add((Expression) QuasiBuilder.substV(
            "L[@i]", "i", new IntegerLiteral(unk, groupIndex)));
      }
      if (!litGroups.isEmpty()) {
        dataObj.appendChild(new ValueProperty(
            litgroupObjKey, new ArrayConstructor(unk, litGroups)));
      }
View Full Code Here

      Map<String, Integer> commonSubstrings, String regex) {
    FilePosition unk = FilePosition.UNKNOWN;
    List<Pair<String, Expression>> substrings = Lists.newArrayList();
    for (Map.Entry<String, Integer> e : commonSubstrings.entrySet()) {
      substrings.add(Pair.pair(e.getKey(), (Expression) QuasiBuilder.substV(
          "s[@i]", "i", new IntegerLiteral(unk, e.getValue()))));
    }
    List<Expression> parts = Lists.newArrayList();
    assert regex.startsWith("/") && regex.endsWith("/i");
    String pattern = regex.substring(1, regex.length() - 2);
    makeRegexpOnto(substrings, pattern, 0, parts);
View Full Code Here

TOP

Related Classes of com.google.caja.parser.js.IntegerLiteral

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.