make ints compile time mutable

to change the label value and use the allocated stubs
This commit is contained in:
Torsten Ruger
2018-05-29 17:03:55 +03:00
parent b81d9565de
commit 7847420d49
5 changed files with 26 additions and 2 deletions

View File

@ -52,6 +52,16 @@ module Parfait
attr_reader :classes , :types , :first_message , :next_integer
attr_reader :true_object , :false_object , :nil_object
# hand out one of the preallocated ints for use as constant
# the same code is hardcoded as risc instructions for "normal" use, to
# avoid the method call at runtime. But at compile time we want to keep
# the number of integers known (fixed).
def get_integer
int = @next_integer
@next_integer = @next_integer.next_integer
int
end
def each_type
@types.values.each do |type|
yield(type)