Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
# encoding: UTF-8
require File.expand_path("nudge", File.dirname(__FILE__))
script = NudgeWriter.new.random
# script = "block { ref x block { ref x do int_multiply ref x value «int» do int_add value «int» do int_multiply } do int_multiply }
# «int»6
# «int»22"
exe = NudgeExecutable.new(script)
exe.bind(:x1 => Value.new(:int, 100), :x2 => Value.new(:int, 200))
exe.bind(:x => Value.new(:int, 100))
#exe.run
puts script
puts "-----------"
3000.times do
break unless top = exe.stacks[:exec].last
case top
when BlockPoint, RefPoint
when ValuePoint
puts "«#{top.instance_variable_get(:@value_type)}» #{top.instance_variable_get(:@value).slice(0..30)}"
when DoPoint
puts "do #{top.instance_variable_get(:@instruction_name)}"
end
exe.step
unless top.is_a?(BlockPoint) || top.is_a?(RefPoint)
puts
puts " bool: " + exe.stacks[:bool].inspect
puts " code: " + exe.stacks[:code].length.to_s
puts " error: " + exe.stacks[:error].length.to_s
puts " float: " + exe.stacks[:float].inspect
puts " int: " + exe.stacks[:int].inspect
puts " name: " + exe.stacks[:name].inspect
puts " ppn: " + exe.stacks[:proportion].inspect
puts "-----------"
end
end