private void validateChildCount(Node n) { int expectedArity = Token.arity(n.getToken()); if (expectedArity != -1) { validateChildCount(n, expectedArity); } }
private static JSType scalarValueToType(int token) { switch (token) { case Token.NUMBER: return JSType.NUMBER; case Token.STRING: return JSType.STRING; case Token.TRUE: return JSType.TRUE_TYPE; case Token.FALSE: return JSType.FALSE_TYPE; case Token.NULL: return JSType.NULL; default: throw new RuntimeException("The token isn't a scalar value " + Token.name(token)); } }
int key(Node n) throws IOException { Integer key = assignments.get(n); if (key == null) { key = keyCount++; assignments.put(n, key); builder.append(INDENT); builder.append(formatNodeName(key)); builder.append(" [label=\""); builder.append(n.getToken().toString()); JSType type = n.getJSType(); if (type != null) { builder.append(" : "); builder.append(type.toString()); } if (printAnnotations && cfg != null && cfg.hasNode(n)) { Object annotation = cfg.getNode(n).getAnnotation(); if (annotation != null) { builder.append("\\n"); builder.append(annotation.toString()); } } builder.append("\""); if (n.getJSDocInfo() != null) { builder.append(" color=\"green\""); } builder.append("];\n"); } return key; }
token = Token.values()[in.readUnsignedByte()]; sourcePosition = readEncodedInt(in); length = readEncodedInt(in);
if (param.isDefaultValue() && Token.EQUALS.equals(paramType.getRoot().getToken())) { paramType = new JSTypeExpression(
/** * Returns the inverse of an operator if it is invertible. * ex. '>' ==> '<' */ static int getInverseOperator(int type) { switch (type) { case Token.GT: return Token.LT; case Token.LT: return Token.GT; case Token.GE: return Token.LE; case Token.LE: return Token.GE; default: throw new IllegalArgumentException( "Unexpected token: " + Token.name(type)); } }
private void validateChildCount(Node n) { int expectedArity = Token.arity(n.getType()); if (expectedArity != -1) { validateChildCount(n, expectedArity); } }
msg = "The result of the '" + n.getToken().toString().toLowerCase() + "' operator is not being used.";
/** * Returns human-readable name of the given node's type. */ private static String getReadableTokenName(Node node) { return Token.name(node.getType()); }
report(t, n, UNEXPECTED_TOKEN, op.toString());
private static String name(Node n) { int type = n.getType(); switch (type) { case Token.VOID: return "VOID"; default: return Token.name(type); } }
report(t, n, UNEXPECTED_TOKEN, n.getToken().toString()); ensureTyped(n); break;
/** * Converts an operator's token value (see {@link Token}) to a string * representation or fails. * * @param operator the operator's token value to convert * @return the string representation * @throws Error if the token value is not an operator */ static String opToStrNoFail(int operator) { String res = opToStr(operator); if (res == null) { throw new Error("Unknown op " + operator + ": " + Token.name(operator)); } return res; }
IncompleteDefinition(Node lValue, boolean inExterns) { super(inExterns); Preconditions.checkNotNull(lValue); Preconditions.checkArgument(ALLOWED_TYPES.contains(lValue.getType()), "Unexpected lValue type %s", Token.name(lValue.getType())); this.lValue = lValue; }
+ Token.name(type) + " (type " + type + ")");
"No arity defined for " + Token.name(token));
private void warnInvalidOperand( Node expr, int operatorType, Object expected, Object actual) { Preconditions.checkArgument( (expected instanceof String) || (expected instanceof JSType)); Preconditions.checkArgument( (actual instanceof String) || (actual instanceof JSType)); if (expected instanceof JSType && actual instanceof JSType) { warnings.add(JSError.make( expr, INVALID_OPERAND_TYPE, Token.name(operatorType), errorMsgWithTypeDiff((JSType) expected, (JSType) actual))); } else { warnings.add(JSError.make( expr, INVALID_OPERAND_TYPE, Token.name(operatorType), "Expected : " + expected.toString() + "\n" + "Found : " + actual.toString() + "\n")); } }