@@ -79,6 +79,12 @@ def assemble_iseq(iseq, lines)
79
79
iseq . branchnil ( labels [ operands ] )
80
80
when "branchunless"
81
81
iseq . branchunless ( labels [ operands ] )
82
+ when "checkkeyword"
83
+ kwbits_index , keyword_index = operands . split ( /,\s */ )
84
+ iseq . checkkeyword (
85
+ parse_number ( kwbits_index ) ,
86
+ parse_number ( keyword_index )
87
+ )
82
88
when "checkmatch"
83
89
iseq . checkmatch ( parse_number ( operands ) )
84
90
when "checktype"
@@ -98,6 +104,8 @@ def assemble_iseq(iseq, lines)
98
104
class_iseq = iseq . class_child_iseq ( name . to_s , Location . default )
99
105
assemble_iseq ( class_iseq , body )
100
106
iseq . defineclass ( name , class_iseq , flags )
107
+ when "defined"
108
+ raise NotImplementedError
101
109
when "definemethod"
102
110
body = parse_nested ( lines [ line_index ..] )
103
111
line_index += body . length
@@ -127,6 +135,12 @@ def assemble_iseq(iseq, lines)
127
135
when "expandarray"
128
136
number , flags = operands . split ( /,\s */ )
129
137
iseq . expandarray ( parse_number ( number ) , parse_number ( flags ) )
138
+ when "getblockparam"
139
+ lookup = find_local ( iseq , operands )
140
+ iseq . getblockparam ( lookup . index , lookup . level )
141
+ when "getblockparamproxy"
142
+ lookup = find_local ( iseq , operands )
143
+ iseq . getblockparamproxy ( lookup . index , lookup . level )
130
144
when "getclassvariable"
131
145
iseq . getclassvariable ( parse_symbol ( operands ) )
132
146
when "getconstant"
@@ -136,18 +150,16 @@ def assemble_iseq(iseq, lines)
136
150
when "getinstancevariable"
137
151
iseq . getinstancevariable ( parse_symbol ( operands ) )
138
152
when "getlocal"
139
- name_string , level_string = operands . split ( /,\s */ )
140
- name = name_string . to_sym
141
- level = level_string &.to_i || 0
142
-
143
- iseq . local_table . plain ( name )
144
- lookup = iseq . local_table . find ( name , level )
153
+ lookup = find_local ( iseq , operands )
145
154
iseq . getlocal ( lookup . index , lookup . level )
146
155
when "getspecial"
147
156
key , type = operands . split ( /,\s */ )
148
157
iseq . getspecial ( parse_number ( key ) , parse_number ( type ) )
149
158
when "intern"
150
159
iseq . intern
160
+ when "invokeblock"
161
+ cdata = operands ? calldata ( operands ) : YARV . calldata ( nil , 0 )
162
+ iseq . invokeblock ( cdata )
151
163
when "invokesuper"
152
164
cdata =
153
165
if operands
@@ -305,17 +317,15 @@ def assemble_iseq(iseq, lines)
305
317
end
306
318
307
319
iseq . send ( calldata ( operands ) , block_iseq )
320
+ when "setblockparam"
321
+ lookup = find_local ( iseq , operands )
322
+ iseq . setblockparam ( lookup . index , lookup . level )
308
323
when "setconstant"
309
324
iseq . setconstant ( parse_symbol ( operands ) )
310
325
when "setglobal"
311
326
iseq . setglobal ( parse_symbol ( operands ) )
312
327
when "setlocal"
313
- name_string , level_string = operands . split ( /,\s */ )
314
- name = name_string . to_sym
315
- level = level_string &.to_i || 0
316
-
317
- iseq . local_table . plain ( name )
318
- lookup = iseq . local_table . find ( name , level )
328
+ lookup = find_local ( iseq , operands )
319
329
iseq . setlocal ( lookup . index , lookup . level )
320
330
when "setn"
321
331
iseq . setn ( parse_number ( operands ) )
@@ -329,6 +339,8 @@ def assemble_iseq(iseq, lines)
329
339
iseq . splatarray ( parse_options ( operands , [ true , false ] ) )
330
340
when "swap"
331
341
iseq . swap
342
+ when "throw"
343
+ iseq . throw ( parse_number ( operands ) )
332
344
when "topn"
333
345
iseq . topn ( parse_number ( operands ) )
334
346
when "toregexp"
@@ -337,12 +349,25 @@ def assemble_iseq(iseq, lines)
337
349
when "ARG_REQ"
338
350
iseq . argument_size += 1
339
351
iseq . local_table . plain ( operands . to_sym )
352
+ when "ARG_BLOCK"
353
+ iseq . argument_options [ :block_start ] = iseq . argument_size
354
+ iseq . local_table . block ( operands . to_sym )
355
+ iseq . argument_size += 1
340
356
else
341
357
raise "Could not understand: #{ line } "
342
358
end
343
359
end
344
360
end
345
361
362
+ def find_local ( iseq , operands )
363
+ name_string , level_string = operands . split ( /,\s */ )
364
+ name = name_string . to_sym
365
+ level = level_string &.to_i || 0
366
+
367
+ iseq . local_table . plain ( name )
368
+ iseq . local_table . find ( name , level )
369
+ end
370
+
346
371
def parse ( value )
347
372
program = SyntaxTree . parse ( value )
348
373
raise if program . statements . body . length != 1
0 commit comments