From 33c62a7db1674fb561ba548d84ac7330f76d0c9c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 26 Jun 2014 17:48:33 +0300 Subject: [PATCH] update reader --- Gemfile.lock | 2 +- lib/ast/all.rb | 1 + lib/virtual/machine.rb | 4 +++- test/virtual/{helper.rb => virtual_helper.rb} | 9 ++++----- 4 files changed, 9 insertions(+), 7 deletions(-) rename test/virtual/{helper.rb => virtual_helper.rb} (76%) diff --git a/Gemfile.lock b/Gemfile.lock index c2ff0a22..9d0f6893 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT GIT remote: https://github.com/ruby-in-ruby/crystal-reader.git - revision: 7e1c0d7f572256b351655798aadfd160ded07760 + revision: 3a56ae1a8d96845bbb80f760626c8203d57cb1c3 specs: crystal-reader (0.1.0) diff --git a/lib/ast/all.rb b/lib/ast/all.rb index 18b824f1..ae40a610 100644 --- a/lib/ast/all.rb +++ b/lib/ast/all.rb @@ -8,3 +8,4 @@ require_relative "module_expression" require_relative "operator_expressions" require_relative "return_expression" require_relative "while_expression" +require_relative "expression_list" diff --git a/lib/virtual/machine.rb b/lib/virtual/machine.rb index 37d558b1..ffeb7015 100644 --- a/lib/virtual/machine.rb +++ b/lib/virtual/machine.rb @@ -1,4 +1,4 @@ -module Vm +module Virtual # The Virtual Machine is a value based virtual machine in which ruby is implemented. While it is value based, # it resembles oo in basic ways of object encapsulation and method invokation, it is a "closed" / static sytem # in that all types are know and there is no dynamic dispatch (so we don't bite our tail here). @@ -42,6 +42,8 @@ module Vm # storage is a linked list. Has the same api as a ha @bindings = List.new end + attr_reader :bindings + # run the instruction stream given. Instructions are a graph and executing means traversing it. # If there is no next instruction the machine stops def run instruction diff --git a/test/virtual/helper.rb b/test/virtual/virtual_helper.rb similarity index 76% rename from test/virtual/helper.rb rename to test/virtual/virtual_helper.rb index 1ab16532..5ca7fb19 100644 --- a/test/virtual/helper.rb +++ b/test/virtual/virtual_helper.rb @@ -11,11 +11,10 @@ module VirtualHelper parser = Parser::Crystal.new syntax = parser.parse_with_debug(@string_input) parts = Parser::Transform.new.apply(syntax) - - parts.each_with_index do |part,index| - expr = part.compile( @object_space.context ) - end - + machine = Virtual::Machine.new + puts parts.class.inspect + parts.compile(machine.bindings) + end end