-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBackPatcher.java
More file actions
46 lines (40 loc) · 797 Bytes
/
Copy pathBackPatcher.java
File metadata and controls
46 lines (40 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//Mark Klara
//mak241@pitt.edu
//CS 1622 - Project 3
//BackPatcher.java
package backpatching;
import java.util.List;
import java.util.HashMap;
import IR.*;
public class BackPatcher
{
private List<Quadruple> IRList;
private HashMap<String, String> workList;
public BackPatcher(List<Quadruple> instructions, HashMap<String, String> work)
{
IRList = instructions;
workList = work;
}
public void patch()
{
for(Quadruple q : IRList)
{
if(q instanceof CallIR)
{
String methodName = (String)q.getArg1();
if(methodName.equals("System.out.println"))
{
q.setArg1("_system_out_println");
}
else if(methodName.equals("System.exit"))
{
q.setArg1("_system_exit");
}
else
{
q.setArg1(workList.get(methodName));
}
}
}
}
}