Add MigrationTools
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / Func.java
CommitLineData
0dc8c589 1package org.tianocore.migration;\r
2\r
3import java.util.regex.*;\r
4\r
5public class Func {\r
6 Func(String r8func,String r8lib,String r9func,String r9lib) {\r
7 r8funcname = r8func;\r
8 r8libname = r8lib;\r
9 r9funcname = r9func;\r
10 r9libname = r9lib;\r
11 }\r
12 Func(String[] linecontext) {\r
13 r8funcname = linecontext[1];\r
14 r8libname = linecontext[0];\r
15 r9funcname = linecontext[2];\r
16 r9libname = linecontext[3];\r
17 }\r
18 public String r8funcname;\r
19 public String r8libname;\r
20 public String r9funcname;\r
21 public String r9libname;\r
22\r
23 public static Pattern ptnbrace = Pattern.compile("\\{[^\\{\\}]*\\}",Pattern.MULTILINE);\r
24 public static Pattern ptnfuncc = Pattern.compile("([a-zA-Z_]\\w*)\\s*\\([^\\)\\(]*\\)",Pattern.MULTILINE);\r
25 public static Pattern ptnfuncd = Pattern.compile("([a-zA-Z_]\\w*)\\s*\\([^\\)\\(]*\\)\\s*@",Pattern.MULTILINE);\r
26 public static Pattern ptnlowcase = Pattern.compile("[a-z]"); // must be removed\r
27 \r
28 private static String reservedwords = "if for pack while switch return sizeof";\r
29 \r
30 public static String register(Matcher mtr, ModuleInfo mi, Database db) {\r
31 String temp = null;\r
32\r
33 temp = mtr.group(1); // both changed and not changed funcc are registered , for finding all the non-local function calls\r
34 Matcher mtrlowcase = ptnlowcase.matcher(temp); // must be removed , so the two funcs can be merged\r
35 if (!reservedwords.contains(temp) && mtrlowcase.find()) {\r
36 mi.hashfuncc.add(temp);\r
37 }\r
38 return temp;\r
39 }\r
40 /*\r
41 public static String registerFuncD(Matcher mtr, ModuleInfo mi, Database db) {\r
42 String temp = null;\r
43\r
44 temp = mtr.group(1); // both changed and not changed funcd are registered , for finding all the non-local function calls\r
45 if (!reservedwords.contains(temp)) {\r
46 mi.hashfuncd.add(temp);\r
47 }\r
48 return temp;\r
49 }\r
50 */\r
51}\r