@@ -136,12 +136,13 @@ where
136
136
trace ! ( "Invoking AML method: {}" , path) ;
137
137
138
138
let object = self . namespace . lock ( ) . get ( path. clone ( ) ) ?. clone ( ) ;
139
- match object. typ ( ) {
140
- ObjectType :: Method => {
139
+ match & * object {
140
+ Object :: Method { .. } => {
141
141
self . namespace . lock ( ) . add_level ( path. clone ( ) , NamespaceLevelKind :: MethodLocals ) ?;
142
142
let context = MethodContext :: new_from_method ( object, args, path) ?;
143
143
self . do_execute_method ( context)
144
144
}
145
+ Object :: NativeMethod ( f) => f ( & args) ,
145
146
_ => Ok ( object) ,
146
147
}
147
148
}
@@ -644,13 +645,22 @@ where
644
645
} )
645
646
. collect ( ) ;
646
647
647
- self . namespace . lock ( ) . add_level ( method_scope. clone ( ) , NamespaceLevelKind :: MethodLocals ) ?;
648
+ if let Object :: Method { .. } = * * method {
649
+ self . namespace
650
+ . lock ( )
651
+ . add_level ( method_scope. clone ( ) , NamespaceLevelKind :: MethodLocals ) ?;
648
652
649
- let new_context =
650
- MethodContext :: new_from_method ( method. clone ( ) , args, method_scope. clone ( ) ) ?;
651
- let old_context = mem:: replace ( & mut context, new_context) ;
652
- self . context_stack . lock ( ) . push ( old_context) ;
653
- context. retire_op ( op) ;
653
+ let new_context =
654
+ MethodContext :: new_from_method ( method. clone ( ) , args, method_scope. clone ( ) ) ?;
655
+ let old_context = mem:: replace ( & mut context, new_context) ;
656
+ self . context_stack . lock ( ) . push ( old_context) ;
657
+ context. retire_op ( op) ;
658
+ } else if let Object :: NativeMethod { ref f, .. } = * * method {
659
+ let result = f ( & args) ?;
660
+ context. contribute_arg ( Argument :: Object ( result) ) ;
661
+ } else {
662
+ panic ! ( ) ;
663
+ }
654
664
}
655
665
Opcode :: Return => {
656
666
let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -1207,7 +1217,8 @@ where
1207
1217
let object = self . namespace . lock ( ) . search ( & name, & context. current_scope ) ;
1208
1218
match object {
1209
1219
Ok ( ( resolved_name, object) ) => {
1210
- if let Object :: Method { flags, .. } = * object {
1220
+ if let Object :: Method { flags, .. } | Object :: NativeMethod { flags, .. } = * object
1221
+ {
1211
1222
context. start_in_flight_op ( OpInFlight :: new_with (
1212
1223
Opcode :: InternalMethodCall ,
1213
1224
vec ! [ Argument :: Object ( object) , Argument :: Namestring ( resolved_name) ] ,
@@ -1762,7 +1773,7 @@ where
1762
1773
Object :: Event => "[Event]" . to_string ( ) ,
1763
1774
Object :: FieldUnit ( _) => "[Field]" . to_string ( ) ,
1764
1775
Object :: Integer ( value) => value. to_string ( ) ,
1765
- Object :: Method { .. } => "[Control Method]" . to_string ( ) ,
1776
+ Object :: Method { .. } | Object :: NativeMethod ( _ ) => "[Control Method]" . to_string ( ) ,
1766
1777
Object :: Mutex { .. } => "[Mutex]" . to_string ( ) ,
1767
1778
Object :: Reference { inner, .. } => resolve_as_string ( & * ( inner. clone ( ) . unwrap_reference ( ) ) ) ,
1768
1779
Object :: OpRegion ( _) => "[Operation Region]" . to_string ( ) ,
0 commit comments