|
|
|
@ -42,6 +42,8 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
protected final Label initcharsLabel = new Label("initchars");
|
|
|
|
|
protected final Label allCharsLabel = new Label("allChars");
|
|
|
|
|
|
|
|
|
|
/** Variable to indicate if Strings are used in the program for optimization */
|
|
|
|
|
private boolean flag = false;
|
|
|
|
|
|
|
|
|
|
/** Operation on None. */
|
|
|
|
|
private final Label errorNone = new Label("error.None");
|
|
|
|
@ -446,6 +448,7 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
@Override
|
|
|
|
|
public Register analyze(StringLiteral node)
|
|
|
|
|
{
|
|
|
|
|
flag=true;
|
|
|
|
|
Label l = constants.getStrConstant(node.value);
|
|
|
|
|
backend.emitLA(Register.A0, l, "Load string literal");
|
|
|
|
|
return Register.A0;
|
|
|
|
@ -490,6 +493,8 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
|
|
|
|
|
private Object getVar(Identifier id)
|
|
|
|
|
{
|
|
|
|
|
if(id.getInferredType().equals(Type.STR_TYPE))
|
|
|
|
|
flag=true;
|
|
|
|
|
SymbolInfo info = sym.get(id.name);
|
|
|
|
|
if(info instanceof StackVarInfo)
|
|
|
|
|
return getStackVar((StackVarInfo)info);
|
|
|
|
@ -1137,9 +1142,13 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
emitStdFunc("strneql");
|
|
|
|
|
emitStdFunc("makeint");
|
|
|
|
|
emitStdFunc("makebool");
|
|
|
|
|
emitStdFunc("initchars");
|
|
|
|
|
emitStdFunc("allChars");
|
|
|
|
|
|
|
|
|
|
if(flag)
|
|
|
|
|
{
|
|
|
|
|
emitStdFunc("initchars");
|
|
|
|
|
emitStdFunc("allChars");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
emitStdFunc("dummy");
|
|
|
|
|
emitErrorFunc(errorNone, "Operation on None");
|
|
|
|
|
emitErrorFunc(errorDiv, "Division by zero");
|
|
|
|
|
emitErrorFunc(errorOob, "Index out of bounds");
|
|
|
|
|