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