|
|
|
@ -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");
|
|
|
|
@ -454,6 +456,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;
|
|
|
|
@ -498,6 +501,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);
|
|
|
|
@ -1145,9 +1150,13 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
emitStdFunc("strneql");
|
|
|
|
|
emitStdFunc("makeint");
|
|
|
|
|
emitStdFunc("makebool");
|
|
|
|
|
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");
|
|
|
|
|