|
|
|
@ -74,6 +74,46 @@ public class ConstOperator extends NoArgOperator { |
|
|
|
|
isInitializer = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String quoted(String str) { |
|
|
|
|
StringBuffer result = new StringBuffer("\""); |
|
|
|
|
for (int i=0; i< str.length(); i++) { |
|
|
|
|
char c; |
|
|
|
|
switch (c = str.charAt(i)) { |
|
|
|
|
case '\0': |
|
|
|
|
result.append("\\0"); |
|
|
|
|
break; |
|
|
|
|
case '\t': |
|
|
|
|
result.append("\\t"); |
|
|
|
|
break; |
|
|
|
|
case '\n': |
|
|
|
|
result.append("\\n"); |
|
|
|
|
break; |
|
|
|
|
case '\r': |
|
|
|
|
result.append("\\r"); |
|
|
|
|
break; |
|
|
|
|
case '\\': |
|
|
|
|
result.append("\\\\"); |
|
|
|
|
break; |
|
|
|
|
case '\"': |
|
|
|
|
result.append("\\\""); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
if (c < 32) { |
|
|
|
|
String oct = Integer.toOctalString(c); |
|
|
|
|
result.append("\\000".substring(0, 4-oct.length())) |
|
|
|
|
.append(oct); |
|
|
|
|
} else if (c >= 32 && c < 127) |
|
|
|
|
result.append(str.charAt(i)); |
|
|
|
|
else { |
|
|
|
|
String hex = Integer.toHexString(c); |
|
|
|
|
result.append("\\u0000".substring(0, 6-hex.length())) |
|
|
|
|
.append(hex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result.append("\"").toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String toString(String[] operands) { |
|
|
|
|
String value = this.value; |
|
|
|
|
if (type.isOfType(Type.tBoolean)) { |
|
|
|
@ -113,6 +153,8 @@ public class ConstOperator extends NoArgOperator { |
|
|
|
|
String hex = Integer.toHexString(c); |
|
|
|
|
return "\'\\u0000".substring(0, 7-hex.length())+hex+"\'"; |
|
|
|
|
} |
|
|
|
|
} else if (type.equals(Type.tString)) { |
|
|
|
|
return quoted(value); |
|
|
|
|
} else if (parent != null) { |
|
|
|
|
int opindex = parent.getOperator().getOperatorIndex(); |
|
|
|
|
if (opindex >= OPASSIGN_OP + ADD_OP |
|
|
|
|