GenCode: StringLit erfolgreich getestet - Strings werden in dynamisch

in den Konstantenpool geschrieben und ausgelesen
This commit is contained in:
Fütterling, Franziska (WWI2012D) 2015-06-25 15:49:22 +02:00
parent d50206a519
commit cef7c777b2
2 changed files with 18 additions and 5 deletions

View File

@ -4,11 +4,15 @@ import de.dhbwstuttgart.typeinference.Menge;
// ino.end
// ino.module.StringLiteral.8653.import
import java.util.Hashtable;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LDC;
@ -108,14 +112,23 @@ public class StringLiteral extends Literal
return "\""+this.string+"\"";
}
public static int counterString = 0;
public String get_String()
// ino.end
// ino.method.get_Name.26246.body
{
return string;
}
//public static int counterString = 0;
@Override
public InstructionList genByteCode(ClassGen cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
ConstantPoolGen cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList();
counterString++;
//counterString++;
//il.append(_factory.ASTORE_1, _factory.createNew(string));
il.append(new LDC(counterString));
cp.addString(get_String());
il.append(new LDC(cp.getSize()-1));
return il;
}

View File

@ -1,7 +1,7 @@
class StringLitTest{
void method() { s; s = "abcdefg"; }
void method() { s; s = "abcdefg"; t; t ="jfowehfowh"; }
}