@@ -58,6 +58,7 @@ public class DynamicObject extends TruffleObject.InstanceBased {
58
58
private static final String ENTERPRISE_PACKAGE = "com.oracle.truffle.object.enterprise" ; // NOI18N
59
59
private static final String ENTERPRISE_LOCATION_TOP_CLASS = ENTERPRISE_PACKAGE +".EnterpriseLocations" ; // NOI18N
60
60
private static final String ENTERPRISE_FIELD_LOCATION_FQN = ENTERPRISE_LOCATION_TOP_CLASS +"$FieldLocation" ; // NOI18N
61
+ private static final String ENTERPRISE_FIELD_INFO_FQN = ENTERPRISE_PACKAGE + ".EnterpriseLayout$FieldInfo" ; // NOI18N
61
62
private static final String PROPERTY_MAP_FQN = "com.oracle.truffle.object.ConsListPropertyMap" ; // NOI18N
62
63
private static final String TRIE_PROPERTY_MAP_FQN = "com.oracle.truffle.object.TriePropertyMap" ; // NOI18N
63
64
private static final String PROPERTY_FQN = "com.oracle.truffle.object.PropertyImpl" ; // NOI18N
@@ -434,6 +435,24 @@ private static boolean isEterpriseFieldLocationObjSubClass(Instance dynObj) {
434
435
return isSubClassOf (dynObj , ENTERPRISE_FIELD_LOCATION_FQN );
435
436
}
436
437
438
+ private static boolean isEterpriseFieldInfoObjSubClass (Instance dynObj ) {
439
+ if (dynObj != null )
440
+ return ENTERPRISE_FIELD_INFO_FQN .equals (dynObj .getJavaClass ().getName ());
441
+ return false ;
442
+ }
443
+
444
+ private static boolean hasFieldInfo (Instance loc ) {
445
+ for (FieldValue fv : loc .getFieldValues ()) {
446
+ if (fv instanceof ObjectFieldValue ) {
447
+ Instance fi = ((ObjectFieldValue )fv ).getInstance ();
448
+ if (isEterpriseFieldInfoObjSubClass (fi )) {
449
+ return true ;
450
+ }
451
+ }
452
+ }
453
+ return false ;
454
+ }
455
+
437
456
private static class Property implements Field {
438
457
439
458
Instance property ;
@@ -874,6 +893,31 @@ private FieldValue getObfuscatedEnperpriseValue(Instance loc, String className,
874
893
return getObfuscatedEnterpriseFieldLocation (dynamicObject , loc , locIndex , locType , locAllowInt );
875
894
}
876
895
}
896
+ if (hasFieldInfo (loc )) {
897
+ Integer locIndex = null ;
898
+ Instance finfo = null ;
899
+ Boolean locAllowInt = null ;
900
+
901
+ for (Object obj : fields ) {
902
+ FieldValue fv = (FieldValue ) obj ;
903
+ Field f = fv .getField ();
904
+ String typeName = f .getType ().getName ();
905
+
906
+ if ("object" .equals (typeName )) { // NOI18N
907
+ Instance val = ((ObjectFieldValue )fv ).getInstance ();
908
+ if (isEterpriseFieldInfoObjSubClass (val )) {
909
+ finfo = val ;
910
+ }
911
+ } else if ("boolean" .equals (typeName ) && fields .size ()==3 && f .getDeclaringClass ().getSubClasses ().size ()==1 ) {
912
+ locAllowInt = (Boolean ) loc .getValueOfField (f .getName ());
913
+ } else if ("int" .equals (typeName )) { // NOI18N
914
+ locIndex = (Integer ) loc .getValueOfField (f .getName ());
915
+ }
916
+ }
917
+ if (locIndex != null && finfo != null ) {
918
+ return getObfuscatedEnterpriseFieldLocation (dynamicObject , loc , locIndex , finfo , locAllowInt );
919
+ }
920
+ }
877
921
if (fields .size () >= 2 ) {
878
922
// ArrayLocation
879
923
Integer locIndex = null ;
@@ -932,7 +976,29 @@ private FieldValue getObfuscatedEnterpriseArrayLocation(Instance dynamicObject,
932
976
return null ;
933
977
}
934
978
935
- private FieldValue getObfuscatedEnterpriseFieldLocation (Instance dynamicObject , Instance loc , Integer index , Instance type , Boolean allowInt ) {
979
+ private FieldValue getObfuscatedEnterpriseFieldLocation (Instance dynamicObject , Instance loc , Integer index , Instance field_type , Boolean allowInt ) {
980
+ Instance type = field_type ;
981
+ if (isEterpriseFieldInfoObjSubClass (field_type )) {
982
+ String fieldName = null ;
983
+ JavaClass fieldType = null ;
984
+ for (FieldValue fv : field_type .getFieldValues ()) {
985
+ if (fv instanceof ObjectFieldValue ) {
986
+ Instance val = ((ObjectFieldValue )fv ).getInstance ();
987
+ if (val == null ) continue ;
988
+ String valName = val .getJavaClass ().getName ();
989
+ if (valName .equals (String .class .getName ())) {
990
+ fieldName = DetailsSupport .getDetailsString (val );
991
+ } else if ("tclass" .equals (fv .getField ().getName ())) {
992
+ type = val ;
993
+ } else if (valName .equals (Class .class .getName ())) {
994
+ fieldType = val .getJavaClass ().getHeap ().getJavaClassByID (val .getInstanceId ());
995
+ }
996
+ }
997
+ }
998
+ assert type .getInstanceId () == dynamicObject .getJavaClass ().getJavaClassId ();
999
+ if (fieldName != null )
1000
+ return getDynamicObjectField (dynamicObject , fieldName , fieldType );
1001
+ }
936
1002
if (type != null ) { // TypedObjectFieldLocation
937
1003
if (index .intValue () == 0 ) { // test for type Object[]
938
1004
long typeClassId = type .getInstanceId (); // NOI18N
@@ -996,6 +1062,15 @@ private boolean isLayoutObjectArrayLocation(Instance location, JavaClass valueCl
996
1062
return false ;
997
1063
}
998
1064
1065
+ private FieldValue getDynamicObjectField (Instance dynamicObject , String fname , JavaClass fieldType ) {
1066
+ for (FieldValue fv : dynamicObject .getFieldValues ()) {
1067
+ if (fv .getField ().getName ().equals (fname )) {
1068
+ return createFieldValue (dynamicObject , fv );
1069
+ }
1070
+ }
1071
+ throw new IllegalArgumentException (fname );
1072
+ }
1073
+
999
1074
private FieldValue getDynamicObjectPrimitiveField (Instance dynamicObject , int index ) {
1000
1075
return getDynamicObjectField (dynamicObject , index , false );
1001
1076
}
0 commit comments