@@ -49,7 +49,10 @@ class root.Method extends AbstractMethodField
4949 parse_descriptor : (@raw_descriptor ) ->
5050 [__ ,param_str ,return_str ] = / \( ([^ )] * )\) (. * )/ .exec (@raw_descriptor )
5151 param_carr = param_str .split ' '
52+ type_size = (t ) -> (if t .toString () in [' D' ,' J' ] then 2 else 1 )
5253 @param_types = (field while (field = carr2type param_carr))
54+ @param_bytes = util .sum (type_size (p) for p in @param_types )
55+ @param_bytes ++ unless @access_flags .static
5356 @num_args = @param_types .length
5457 @num_args ++ unless @access_flags .static # nonstatic methods get 'this'
5558 @return_type = str2type return_str
@@ -67,16 +70,9 @@ class root.Method extends AbstractMethodField
6770 signature : rs .init_string @raw_descriptor
6871 }
6972
70- param_bytes : () ->
71- type_size = (t ) -> (if t .toString () in [' D' ,' J' ] then 2 else 1 )
72- n_bytes = util .sum (type_size (p) for p in @param_types )
73- n_bytes++ unless @access_flags .static
74- n_bytes
75-
7673 take_params : (caller_stack ) ->
7774 params = []
78- n_bytes = @ param_bytes ()
79- caller_stack .splice (caller_stack .length - n_bytes,n_bytes)
75+ caller_stack .splice (caller_stack .length - @param_bytes , @param_bytes )
8076
8177 # used by run and run_manually to print arrays for debugging. we need this to
8278 # distinguish [null] from [].
@@ -172,8 +168,8 @@ class root.Method extends AbstractMethodField
172168 caller_stack = runtime_state .curr_frame ().stack
173169 if virtual
174170 # dirty hack to bounce up the inheritance tree, to make sure we call the method on the most specific type
175- oref = caller_stack[caller_stack .length - @ param_bytes () ]
176- error " undef'd oref: (#{ caller_stack} )[-#{ @ param_bytes () } ] (#{ sig} )" unless oref
171+ oref = caller_stack[caller_stack .length - @param_bytes ]
172+ error " undef'd oref: (#{ caller_stack} )[-#{ @param_bytes } ] (#{ sig} )" unless oref
177173 obj = runtime_state .get_obj (oref)
178174 m_spec = {class : obj .type .toClassString (), sig : @name + @raw_descriptor }
179175 m = runtime_state .method_lookup (m_spec)
0 commit comments