mirror of
https://github.com/hazemKrimi/jack-vm-translator.git
synced 2026-05-01 18:00:27 +00:00
Move method
This commit is contained in:
+20
-20
@@ -22,6 +22,26 @@ private:
|
|||||||
string filename;
|
string filename;
|
||||||
vector<vector<string>> commands;
|
vector<vector<string>> commands;
|
||||||
|
|
||||||
|
Segment determineSegment(string segment)
|
||||||
|
{
|
||||||
|
if (segment == "local")
|
||||||
|
return Segment::LCL;
|
||||||
|
if (segment == "argument")
|
||||||
|
return Segment::ARG;
|
||||||
|
if (segment == "this")
|
||||||
|
return Segment::THIS;
|
||||||
|
if (segment == "that")
|
||||||
|
return Segment::THAT;
|
||||||
|
if (segment == "static")
|
||||||
|
return Segment::STATIC;
|
||||||
|
if (segment == "temp")
|
||||||
|
return Segment::TEMP;
|
||||||
|
if (segment == "constant")
|
||||||
|
return Segment::CONSTANT;
|
||||||
|
|
||||||
|
return Segment::CONSTANT;
|
||||||
|
}
|
||||||
|
|
||||||
string translatePush(Segment segment, int index)
|
string translatePush(Segment segment, int index)
|
||||||
{
|
{
|
||||||
stringstream output;
|
stringstream output;
|
||||||
@@ -80,26 +100,6 @@ private:
|
|||||||
return output.str();
|
return output.str();
|
||||||
};
|
};
|
||||||
|
|
||||||
Segment determineSegment(string segment)
|
|
||||||
{
|
|
||||||
if (segment == "local")
|
|
||||||
return Segment::LCL;
|
|
||||||
if (segment == "argument")
|
|
||||||
return Segment::ARG;
|
|
||||||
if (segment == "this")
|
|
||||||
return Segment::THIS;
|
|
||||||
if (segment == "that")
|
|
||||||
return Segment::THAT;
|
|
||||||
if (segment == "static")
|
|
||||||
return Segment::STATIC;
|
|
||||||
if (segment == "temp")
|
|
||||||
return Segment::TEMP;
|
|
||||||
if (segment == "constant")
|
|
||||||
return Segment::CONSTANT;
|
|
||||||
|
|
||||||
return Segment::CONSTANT;
|
|
||||||
}
|
|
||||||
|
|
||||||
string translatePop(Segment segment, int index)
|
string translatePop(Segment segment, int index)
|
||||||
{
|
{
|
||||||
stringstream output;
|
stringstream output;
|
||||||
|
|||||||
Reference in New Issue
Block a user