2014-06-25 14:20:46 +02:00
|
|
|
require_relative '../helper'
|
|
|
|
require 'parslet/convenience'
|
|
|
|
|
2014-06-26 10:34:48 +02:00
|
|
|
module VirtualHelper
|
2014-06-25 14:20:46 +02:00
|
|
|
# need a code generator, for arm
|
|
|
|
def setup
|
2014-06-26 10:34:48 +02:00
|
|
|
# @object_space = Boot::BootSpace.new "Arm"
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
|
|
|
|
2014-07-30 20:07:48 +02:00
|
|
|
def check
|
2014-06-26 16:48:33 +02:00
|
|
|
machine = Virtual::Machine.new
|
2014-07-30 20:07:48 +02:00
|
|
|
parts = machine.read @string_input
|
2014-07-16 18:24:41 +02:00
|
|
|
main = Virtual::MethodDefinition.main
|
2014-07-25 10:48:06 +02:00
|
|
|
expressions = parts.compile( main, machine.message )
|
2014-07-18 10:16:56 +02:00
|
|
|
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
|
|
|
assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + expressions.to_yaml
|
2014-06-25 14:20:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2014-07-19 20:56:17 +02:00
|
|
|
|
|
|
|
require "yaml" # not my first choice, but easy with graphs
|
|
|
|
# for readability of the yaml output :next of instructions last
|
|
|
|
|
|
|
|
Psych::Visitors::YAMLTree.class_eval do
|
|
|
|
private
|
|
|
|
def dump_ivars target
|
|
|
|
ivars = find_ivars target
|
|
|
|
ivars << :@next if ivars.delete(:@next)
|
|
|
|
ivars.each do |iv|
|
|
|
|
@emitter.scalar("#{iv.to_s.sub(/^@/, '')}", nil, nil, true, false, Psych::Nodes::Scalar::ANY)
|
|
|
|
accept target.instance_variable_get(iv)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|