Mercurial > hg > graal-compiler
annotate agent/src/share/classes/sun/jvm/hotspot/utilities/CPPExpressions.java @ 2426:1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair
author | trims |
---|---|
date | Tue, 05 Apr 2011 14:12:31 -0700 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.utilities; | |
26 | |
27 import java.util.regex.*; | |
28 | |
29 /** Provides helper routines for parsing simple C++ expressions such | |
30 as "(JavaThread *) 0xf00" and "Universe::_collectedHeap". */ | |
31 | |
32 public class CPPExpressions { | |
33 private static Pattern castPattern; | |
34 | |
35 /** Represents a cast expression such as "(JavaThread *) | |
36 0xf00". Returns both the type to which we are casting as well as | |
37 the address. */ | |
38 public static class CastExpr { | |
39 private String type; | |
40 private String address; | |
41 | |
42 private CastExpr(String type, String address) { | |
43 this.type = type; | |
44 this.address = address; | |
45 } | |
46 | |
47 public String getType() { | |
48 return type; | |
49 } | |
50 | |
51 public String getAddress() { | |
52 return address; | |
53 } | |
54 } | |
55 | |
56 /** Represents a static field expression such as "Universe::_collectedHeap". */ | |
57 public static class StaticFieldExpr { | |
58 private String containingType; | |
59 private String fieldName; | |
60 | |
61 private StaticFieldExpr(String containingType, String fieldName) { | |
62 this.containingType = containingType; | |
63 this.fieldName = fieldName; | |
64 } | |
65 | |
66 public String getContainingType() { | |
67 return containingType; | |
68 } | |
69 | |
70 public String getFieldName() { | |
71 return fieldName; | |
72 } | |
73 } | |
74 | |
75 /** Attempts to parse the given string into a CastExpr. Returns null | |
76 if the string did not match the supported pattern. */ | |
77 public static CastExpr parseCast(String expr) { | |
78 if (castPattern == null) { | |
79 castPattern = Pattern.compile("\\s*\\(\\s*([0-9A-Za-z:_]*)\\s*\\*\\s*\\)\\s*([0-9a-zA-Z]*)\\s*"); | |
80 } | |
81 Matcher matcher = castPattern.matcher(expr); | |
82 if (matcher.matches()) { | |
83 String type = matcher.group(1); | |
84 String addr = matcher.group(2); | |
85 return new CastExpr(type, addr); | |
86 } | |
87 return null; | |
88 } | |
89 | |
90 /** Attempts to parse the given string into a | |
91 StaticFieldExpr. Returns null if the string did not match the | |
92 supported pattern. */ | |
93 public static StaticFieldExpr parseStaticField(String expr) { | |
94 String sep = "::"; | |
95 int idx = expr.lastIndexOf(sep); | |
96 if (idx < 0) { | |
97 return null; | |
98 } | |
99 String containingType = expr.substring(0, idx); | |
100 String fieldName = expr.substring(idx + sep.length(), expr.length()); | |
101 return new StaticFieldExpr(containingType, fieldName); | |
102 } | |
103 } |