public static Constant parseChar(final String orig) { String string = orig; int len = string.length(); if (len <= 2 || string.charAt(0) != '\'' || string.charAt(len - 1) != '\'') throw new IllegalArgumentException("Expecting char, got " + string); string = string.substring(1, len - 1); return new Constant(Type.Char, parseNakedString(string).charAt(0), orig); }
public static Constant parseFloat(final String orig) { String string = orig; string = string.trim().toLowerCase(); if (string.length() > 0) { int lm1 = string.length() - 1; char c = string.charAt(lm1); if (Character.isLetter(c)) { String beg = string.substring(0, lm1); if (c == 'f') return new Constant(Type.Float, Float.parseFloat(beg), orig); } } return new Constant(Type.Double, Double.parseDouble(string), orig); } static final String[] trailingTypeInfos = new String[] { "ll", "li", "l", "s", "u" };
public static Constant parseString(final String orig) { String string = orig; int len = string.length(); if (len < 2 || string.charAt(0) != '"' || string.charAt(len - 1) != '"') throw new IllegalArgumentException("Expecting string, got " + string); string = string.substring(1, len - 1); return new Constant(Type.String, parseNakedString(string), orig); }
return new Constant(tpe, form, value, orig);
return new Constant(type, getValue(), txt);
case Char: case String: expr = methodCall(ident("v8", "String", "New"), new Expression.Constant(valueType, value + "", null)); break; case Null:
case Char: case String: expr = methodCall(ident("v8", "String", "New"), new Expression.Constant(valueType, value + "", null)); break; case Null:
return new Constant(Type.IntegerString, IntForm.String, (int)result, orig); else return new Constant(Type.LongString, IntForm.String, result, orig); throw new IllegalArgumentException("Expected char, go string of length " + parsed.length() + ": '" + parsed + "'"); return new Constant(Type.Char, parsed.charAt(0), orig);
public static Constant parseStringInteger(final String orig) { String string = orig; int len = string.length(); if (len <= 2 || string.charAt(0) != '\'' || string.charAt(len - 1) != '\'' || ((len -= 2) != 4 && len != 8)) throw new IllegalArgumentException("Expecting 'xxxx' or 'xxxxxxxx', got " + string); string = string.substring(1, len - 1); long result = 0; for (int i = len; i-- != 0;) { result = result << 8 | (int)string.charAt(i); } if (len == 4) return new Constant(Type.Int, IntForm.String, (int)result, orig); else return new Constant(Type.Long, IntForm.String, result, orig); }
public static Constant string(final String s) { return new Constant(Type.String, s, s); }
public static Constant newNull() { return new Constant(Constant.Type.Null, null, null); }
public static Expression expr(Constant.Type type, Object value) { return new Constant(type, value, null); }