1 module PrimitiveGenerator
2 def self.generate(method)
3 @types = [] # clean slate before going
8 def self.generate_checks
9 arity = @types.length - 1
10 raise "Primitive MUST pop self" unless arity >= 0
11 variables = %w(self t1 t2 t3)
13 rval = " ARITY(#{arity})\n"
14 while (type = @types.shift)
15 variable = variables.shift
16 rval << " POP(#{variable}, #{type})\n"
21 def self.push_type(name)
23 @types << name.to_s.upcase
26 def method_missing(name, *args, &block)
27 PrimitiveGenerator.push_type(name)
31 PrimitiveGenerator.push_type('FALSE')
35 PrimitiveGenerator.push_type('TRUE')
39 PrimitiveGenerator.push_type('NIL')