public Integer asInteger() { switch (getType()) { case Int: case IntegerString: return (Integer)value; } throw new ClassCastException("Constant " + getValue() + " is not an integer, but a " + getType()); }
append(txt); } else { Object value = e.getValue(); if (e.getIntForm() == IntForm.Hex) { append("0x", Long.toHexString(value instanceof Long ? ((Long) value).longValue() : ((Integer) value).longValue()).toUpperCase());
declarator.setName(String.valueOf(Constant.parseString((fieldName!=null?fieldName.getText():null)).getValue()));
String s = String.valueOf(Constant.parseString((an!=null?an.getText():null)).getValue()); if (retval.asmName == null) retval.asmName = s;
return; Object value = getValue(); switch (type) { case Int:
@Override public void visitConstant(Constant c) { if (c.getValue() instanceof String) { //Struct s = c.findParentOfType(Struct.class); Class charClass; String ptrMethodName; if (c.getType() == Constant.Type.LongString) { charClass = Short.class; ptrMethodName = "pointerToWideCString"; } else { charClass = Byte.class; ptrMethodName = "pointerToCString"; } String fieldName = "strConstant" + (++nConstants); VariablesDeclaration staticConstField = new VariablesDeclaration(typeRef(ident(ptrClass(), expr(typeRef(charClass)))), new DirectDeclarator(fieldName, staticPtrMethod(ptrMethodName, c.clone()))); staticConstField.addModifiers(ModifierType.Static, ModifierType.Private, ModifierType.Final); //s.addDeclaration(staticConstField); extraDeclarationsOut.add(staticConstField); c.replaceBy(varRef(fieldName)); return; } super.visitConstant(c); } //
@Override public void visitConstant(Constant c) { if (c.getValue() instanceof String) { //Struct s = c.findParentOfType(Struct.class); Class charClass; String ptrMethodName; if (c.getType() == Constant.Type.LongString) { charClass = Short.class; ptrMethodName = "pointerToWideCString"; } else { charClass = Byte.class; ptrMethodName = "pointerToCString"; } String fieldName = "strConstant" + (++nConstants); VariablesDeclaration staticConstField = new VariablesDeclaration(typeRef(ident(ptrClass(), expr(typeRef(charClass)))), new DirectDeclarator(fieldName, staticPtrMethod(ptrMethodName, c.clone()))); staticConstField.addModifiers(ModifierType.Static, ModifierType.Private, ModifierType.Final); //s.addDeclaration(staticConstField); extraDeclarationsOut.add(staticConstField); c.replaceBy(varRef(fieldName)); return; } super.visitConstant(c); } //