From 99c719251d9143ecf41b0ec45f74fa6b2f28e8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Thu, 18 Jun 2015 12:34:09 +0200 Subject: [PATCH] Null eingefuegt --- src/de/dhbwstuttgart/syntaxtree/statement/Expr.java | 7 ++++++- src/de/dhbwstuttgart/syntaxtree/statement/Null.java | 12 +++++++++--- .../dhbwstuttgart/syntaxtree/statement/Return.java | 4 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java index e62b9c53..f625c9ed 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java @@ -4,8 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement; // ino.module.Expr.8630.import import java.util.Hashtable; import java.util.Iterator; -import de.dhbwstuttgart.typeinference.Menge; +import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.InstructionList; + +import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.syntaxtree.Class; @@ -109,5 +112,7 @@ public abstract class Expr extends ExprStmt public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen. } + + public abstract InstructionList genByteCode(ClassGen _cg); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java index 5cac43a3..f69eaa27 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java @@ -5,6 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; import org.apache.bcel.generic.ClassGen; +import org.apache.bcel.generic.InstructionFactory; +import org.apache.bcel.generic.InstructionList; import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; @@ -91,10 +93,14 @@ public class Null extends Literal } @Override - public void genByteCode(ClassGen _cg) { - // TODO Auto-generated method stub + public InstructionList genByteCode(ClassGen cg) { + InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool()); + InstructionList il = new InstructionList(); + il.append(_factory.ACONST_NULL); + + return il; } - + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java index 0e513996..7cef4cf9 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java @@ -134,8 +134,10 @@ public class Return extends Statement @Override public InstructionList genByteCode(ClassGen cg) { + InstructionList il = retexpr.genByteCode(cg); + InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool()); - InstructionList il = new InstructionList(); + il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); //TO BE DONE