From 42270e743e396063b26b9c3216ec6e101f1f13f1 Mon Sep 17 00:00:00 2001 From: zjf <836331547@qq.com> Date: Mon, 10 Dec 2018 10:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=A9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IntermediateCodeGenerate.cpp | 22 ++++++++++++++++++++-- IntermediateCodeGenerate.h | 6 ++++++ test.cpp | 4 ++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test.cpp diff --git a/IntermediateCodeGenerate.cpp b/IntermediateCodeGenerate.cpp index ce8190a..25e9725 100644 --- a/IntermediateCodeGenerate.cpp +++ b/IntermediateCodeGenerate.cpp @@ -2,9 +2,7 @@ // Created by IceCapriccio on 2018/12/3. // -#include #include "IntermediateCodeGenerate.h" -#include "SyntaxAnalyse.h" SymbolTable SyntaxAnalyse::symbolTable; SupportTable supportTable; @@ -16,6 +14,26 @@ CodeTerm::CodeTerm(Type op, int param1, int param2, int dest) : op(op), param1(param1), param2(param2), dest(dest) { } +Type CodeTerm::getOp() +{ + return op; +} + +int CodeTerm::getParam1() +{ + return param1; +} + +int CodeTerm::getParam2() +{ + return param2; +} + +int CodeTerm::getDest() +{ + return dest; +} + void CodeTerm::show() { int idx = op; cout << '(' << name[idx] << ',' << param1 << ',' << param2 << ',' << dest << ')' << endl; diff --git a/IntermediateCodeGenerate.h b/IntermediateCodeGenerate.h index cf3a3fb..5144210 100644 --- a/IntermediateCodeGenerate.h +++ b/IntermediateCodeGenerate.h @@ -5,6 +5,8 @@ #ifndef COMPILER_INTERMEDITECODEGENERATE_H #define COMPILER_INTERMEDITECODEGENERATE_H +#include +#include "SyntaxAnalyse.h" #include #include "SemanticAnalyse.h" @@ -15,6 +17,10 @@ class CodeTerm { public: Type type; CodeTerm(Type op, int param1, int param2, int dest); + Type getOp(); + int getParam1(); + int getParam2(); + int getDest(); void show(); }; diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..7328ff7 --- /dev/null +++ b/test.cpp @@ -0,0 +1,4 @@ +// +// Created by zjf on 2018/12/9. +// +