mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch 'origin/GP-5219_ghizard_CPP_PDB_improve_uniqueness_mech_for_ClassFieldAttributes'
This commit is contained in:
commit
be7e589bbd
3 changed files with 20 additions and 12 deletions
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -19,7 +19,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class access attributes
|
||||||
*/
|
*/
|
||||||
//----------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------
|
||||||
// TODO: Consider expanding these beyond C++.
|
// TODO: Consider expanding these beyond C++.
|
||||||
|
|
|
@ -15,28 +15,36 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.app.util.pdb.classtype;
|
package ghidra.app.util.pdb.classtype;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Objects;
|
||||||
|
|
||||||
import ghidra.app.util.bin.format.pdb2.pdbreader.type.ClassFieldMsAttributes;
|
import ghidra.app.util.bin.format.pdb2.pdbreader.type.ClassFieldMsAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class field attributes
|
||||||
*/
|
*/
|
||||||
public class ClassFieldAttributes {
|
public class ClassFieldAttributes {
|
||||||
|
|
||||||
private static final Map<ClassFieldAttributes, ClassFieldAttributes> map = new HashMap<>();
|
private static final ClassFieldAttributes all[][] =
|
||||||
|
new ClassFieldAttributes[Access.values().length][Property.values().length];
|
||||||
|
|
||||||
// These initializations use the map above, so it must be initialized first
|
static {
|
||||||
|
for (Access access : Access.values()) {
|
||||||
|
for (Property property : Property.values()) {
|
||||||
|
all[access.ordinal()][property.ordinal()] =
|
||||||
|
new ClassFieldAttributes(access, property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// These initializations use the 'all' array above, so it must be initialized first
|
||||||
public static final ClassFieldAttributes UNKNOWN = get(Access.UNKNOWN, Property.UNKNOWN);
|
public static final ClassFieldAttributes UNKNOWN = get(Access.UNKNOWN, Property.UNKNOWN);
|
||||||
public static final ClassFieldAttributes BLANK = get(Access.BLANK, Property.BLANK);
|
public static final ClassFieldAttributes BLANK = get(Access.BLANK, Property.BLANK);
|
||||||
|
|
||||||
private final Access access;
|
private final Access access;
|
||||||
private final Property property;
|
private final Property property;
|
||||||
|
|
||||||
public synchronized static ClassFieldAttributes get(Access access, Property property) {
|
public static ClassFieldAttributes get(Access access, Property property) {
|
||||||
ClassFieldAttributes key = new ClassFieldAttributes(access, property);
|
return all[access.ordinal()][property.ordinal()];
|
||||||
ClassFieldAttributes cfa = map.putIfAbsent(key, key);
|
|
||||||
return (cfa != null) ? cfa : key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassFieldAttributes convert(ClassFieldMsAttributes msAtts,
|
public static ClassFieldAttributes convert(ClassFieldMsAttributes msAtts,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class properties
|
||||||
*/
|
*/
|
||||||
public enum Property {
|
public enum Property {
|
||||||
UNKNOWN("INVALID_PROPERTY", -1),
|
UNKNOWN("INVALID_PROPERTY", -1),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue