]>
Commit | Line | Data |
---|---|---|
b0282412 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
0dc8c589 | 13 | package org.tianocore.migration;\r |
14 | \r | |
71f30e51 | 15 | import java.util.regex.Matcher;\r |
16 | import java.util.regex.Pattern;\r | |
0dc8c589 | 17 | \r |
18 | public class Func {\r | |
71f30e51 | 19 | Func(String r8func, String r8lib, String r9func, String r9lib) {\r |
20 | r8funcname = r8func;\r | |
21 | r8libname = r8lib;\r | |
22 | r9funcname = r9func;\r | |
23 | r9libname = r9lib;\r | |
24 | }\r | |
25 | \r | |
26 | Func(String[] linecontext) {\r | |
27 | r8funcname = linecontext[1];\r | |
28 | r8libname = linecontext[0];\r | |
29 | r9funcname = linecontext[2];\r | |
30 | if (r9funcname.contains("n/a")) {\r | |
31 | r9funcname = "#error Unknown or missing library function in EDKII: "\r | |
32 | + r8funcname;\r | |
33 | }\r | |
34 | r9libname = linecontext[3];\r | |
35 | }\r | |
36 | \r | |
37 | public String r8funcname;\r | |
38 | \r | |
39 | public String r8libname;\r | |
40 | \r | |
41 | public String r9funcname;\r | |
42 | \r | |
43 | public String r9libname;\r | |
44 | \r | |
45 | public static Pattern ptnbrace = Pattern.compile("\\{[^\\{\\}]*\\}",\r | |
46 | Pattern.MULTILINE);\r | |
47 | \r | |
48 | public static Pattern ptnfuncc = Pattern.compile(\r | |
49 | "(?<!->)([a-zA-Z_]\\w*)\\s*\\(", Pattern.MULTILINE);\r | |
50 | \r | |
51 | public static Pattern ptnfuncd = Pattern.compile(\r | |
52 | "([a-zA-Z_]\\w*)\\s*\\([^\\)\\(]*\\)\\s*@", Pattern.MULTILINE);\r | |
53 | \r | |
54 | public static Pattern ptnlowcase = Pattern.compile("[a-z]"); // must be\r | |
55 | // removed\r | |
56 | \r | |
57 | private static String reservedwords = "if for pack while switch return sizeof";\r | |
58 | \r | |
59 | public static String register(Matcher mtr, ModuleInfo mi, Database db) {\r | |
60 | String temp = null;\r | |
61 | \r | |
62 | temp = mtr.group(1); // both changed and not changed funcc are\r | |
63 | // registered , for finding all the non-local\r | |
64 | // function calls\r | |
65 | Matcher mtrlowcase = ptnlowcase.matcher(temp); // must be removed , so\r | |
66 | // the two funcs can be\r | |
67 | // merged\r | |
68 | if (!reservedwords.contains(temp) && mtrlowcase.find()) {\r | |
69 | mi.hashfuncc.add(temp);\r | |
70 | }\r | |
71 | return temp;\r | |
72 | }\r | |
0dc8c589 | 73 | }\r |