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.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.Unify;
|
import de.dhbwstuttgart.typeinference.unify.Unify;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ForStmt extends Statement
|
public class ForStmt extends Statement
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -6,7 +6,11 @@ import java.util.Enumeration;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
import org.apache.commons.bcel6.generic.ClassGen;
|
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 org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
@ -139,8 +143,20 @@ public class WhileStmt extends Statement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
// TODO Bytecode
|
//TOD: while Statement
|
||||||
throw new NotImplementedException();
|
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
|
// ino.end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class IfElse{
|
class ForTest{
|
||||||
method(){
|
void method(){
|
||||||
for( i = 0; i < 10 ; i = i++){
|
for(Integer i = 0; i < 10 ; i = i + 1){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
class IfElse{
|
class WhileTest{
|
||||||
method(){
|
void method(){
|
||||||
while(true){
|
Integer i;
|
||||||
|
i = 1;
|
||||||
|
while(i < 10){
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user