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