File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
src/vm/jvm/runtime/org/perl6/nqp/runtime Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -2732,12 +2732,22 @@ else if (tc.native_type == ThreadContext.NATIVE_STR) {
2732
2732
retval = box_s ((String )tc .native_s , tc .curFrame .codeRef .staticInfo .compUnit .hllConfig .strBoxType , tc );
2733
2733
}
2734
2734
else if (tc .native_type == ThreadContext .NATIVE_JVM_OBJ ) {
2735
- /* XXX: there might be other cases and we have to figure out, what kind of
2736
- REPR we need to properly wrap around the NATIVE_JVM_OBJ we goet here,
2737
- but so far this seems to cover what's needed. */
2738
- retval = REPRRegistry .getByName ("NativeCall" ).allocate (tc ,
2739
- REPRRegistry .getByName ("NativeCall" ).type_object_for (tc , tc .gc .KnowHOW ).st );
2740
- ((NativeCallInstance )retval ).body = (NativeCallBody ) tc .native_j ;
2735
+ int slot = ((P6OpaqueBaseInstance )obj ).resolveAttribute (obj .st .WHAT , name );
2736
+ STable attr_st = ((P6OpaqueREPRData ) obj .st .REPRData ).flattenedSTables [slot ];
2737
+ if (attr_st != null ) {
2738
+ retval = attr_st .REPR .allocate (tc , attr_st );
2739
+ for (Field field : retval .getClass ().getDeclaredFields ()) {
2740
+ try {
2741
+ if (field .getType ().isAssignableFrom (tc .native_j .getClass ())) {
2742
+ field .set (retval , tc .native_j );
2743
+ break ;
2744
+ }
2745
+ }
2746
+ catch (IllegalAccessException iae ) {
2747
+ throw ExceptionHandling .dieInternal (tc , "Attribute '" + name + "' couldn't be boxed" );
2748
+ }
2749
+ }
2750
+ }
2741
2751
}
2742
2752
return retval ;
2743
2753
}
You can’t perform that action at this time.
0 commit comments