From 65a1038574595089cdd0279ba178f41165e08496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Thu, 14 Apr 2016 14:53:18 +0200 Subject: [PATCH] - Speichern einer lokalen Variable unter Verwenung der InstructionFactory --- src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java | 4 ++++ src/de/dhbwstuttgart/syntaxtree/statement/Assign.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java b/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java index bc5a3806..6cf24c88 100644 --- a/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java +++ b/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java @@ -143,6 +143,10 @@ public class DHBWInstructionFactory extends InstructionFactory{ return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName)); } + public LocalVariableInstruction createStore(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) { + return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName)); + } + public Integer getStoreIndex(String variableName) { if(storeIndexes.get(variableName) == null){ Integer index = storeIndexes.size()+1; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java index 9e863d01..9dfb6560 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java @@ -208,7 +208,7 @@ public class Assign extends Expr } */ //Es wird momentan immer von RefType ausgegangen: - il.append(new ASTORE(_factory.getStoreIndex(expr1.get_Name()))); + il.append(_factory.createStore(expr2.getType().getBytecodeType(cg, rs), expr1.get_Name())); return il; }