package interpres.ast;

import java.util.List;
import java.util.ArrayList;

import interpres.language.DefinitionTable;
import interpres.language.values.Value;

public class StringLiteral extends AST {
  private String literal;

  public StringLiteral(String literal) {
    this.literal = literal;
  }

  public Value evaluate(DefinitionTable definitionTable) {
    List<String> instructions = new ArrayList<String>();

    for (int i = literal.length() - 1; i >= 0; i--) {
      instructions.add("LOADL " + (int) literal.charAt(i));
    }

    return new interpres.language.values.List(instructions);
  }

  public String quote() {
    return this.literal;
  }
}


@@ -362,241 +362,113 @@
     
-List%3CString%3E instructions = new ArrayList%3CString%3E();%0A%0A    for (int i = literal.length() - 1; i %3E= 0; i--) %7B%0A      instructions.add(%22LOADL %22 + (int) literal.charAt(i));%0A    %7D%0A%0A    return new interpres.language.values.List(instructions
+return ListExpression.buildFunctionCall(%22asm.loads%22, new QuotedExpression(this)).evaluate(definitionTable
 );%0A 

Call asm.loads when a string is encountered