Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Prism] Fix cvar or assignment instructions
The instructions for `PM_CLASS_VARIABLE_OR_WRITE_NODE` were incorrect as they were missing a `putnil`, a `defined`, and a `branchunless`. I verified this is fixed via the instructions and running the following: `RUBY_ISEQ_DUMP_DEBUG=prism make test/csv/interface/test_read_write.rb`. These new instructions can't go in the defined function because `defined?(@@Fop ||= 1)` should return "assignment" not "class variable". Instructions before: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(30,11)> 0000 putnil ( 30)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:29 (29,0)-(29,11)> 0000 getclassvariable :@@foo, <is:0> ( 29)[Li] 0003 dup 0004 branchif 13 0006 pop 0007 putobject 1 0009 dup 0010 setclassvariable :@@foo, <is:0> 0013 leave ``` Instructions after: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(30,11)> 0000 putnil ( 30)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:29 (29,0)-(29,11)> 0000 putnil ( 29)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave ``` Fixes ruby/prism#2064
- Loading branch information