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