forked from JavaTX/JavaCompilerCore
-Tests für for und While Schleife korrigiert
- While teilweise implementiert
This commit is contained in:
parent
dad06a5626
commit
ba6ae74ad1
@ -39,10 +39,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unify;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class ForStmt extends Statement
|
||||
{
|
||||
|
||||
|
@ -6,7 +6,11 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||
import org.apache.commons.bcel6.generic.ClassGen;
|
||||
import org.apache.commons.bcel6.generic.DUP;
|
||||
import org.apache.commons.bcel6.generic.GOTO;
|
||||
import org.apache.commons.bcel6.generic.IFEQ;
|
||||
import org.apache.commons.bcel6.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
@ -139,8 +143,20 @@ public class WhileStmt extends Statement
|
||||
|
||||
@Override
|
||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||
// TODO Bytecode
|
||||
throw new NotImplementedException();
|
||||
//TOD: while Statement
|
||||
InstructionList il = expr.genByteCode(_cg, rs);
|
||||
|
||||
BranchInstruction ifeq = new IFEQ(null);
|
||||
il.append(ifeq);
|
||||
|
||||
il.append(loop_block.genByteCode(_cg, rs));
|
||||
|
||||
il.append(new GOTO(il.getStart()));
|
||||
|
||||
ifeq.setTarget(il.append(new DUP()));
|
||||
|
||||
|
||||
return il;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,6 +1,6 @@
|
||||
class IfElse{
|
||||
method(){
|
||||
for( i = 0; i < 10 ; i = i++){
|
||||
class ForTest{
|
||||
void method(){
|
||||
for(Integer i = 0; i < 10 ; i = i + 1){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
class IfElse{
|
||||
method(){
|
||||
while(true){
|
||||
|
||||
class WhileTest{
|
||||
void method(){
|
||||
Integer i;
|
||||
i = 1;
|
||||
while(i < 10){
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user