More or less a stash
This commit is contained in:
parent
37571a0ff9
commit
86e3103543
@ -95,15 +95,19 @@ module RubyX
|
||||
@vool << ruby_tree.to_vool
|
||||
end
|
||||
|
||||
def load_parfait
|
||||
parfait = ["object"]
|
||||
parfait.each do |file|
|
||||
path = File.expand_path("../../parfait/#{file}.rb",__FILE__)
|
||||
ruby_to_vool(File.read(path))
|
||||
end
|
||||
end
|
||||
|
||||
def self.ruby_to_binary( ruby , platform , options)
|
||||
compiler = RubyXCompiler.new(options)
|
||||
# compiler.load_parfait
|
||||
compiler.ruby_to_vool(ruby)
|
||||
|
||||
# integrate other sources into vool tree
|
||||
|
||||
compiler.to_binary(platform)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1 +1,14 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Parfait
|
||||
class ParfaitRewriter < AST::Processor
|
||||
include AST::Sexp
|
||||
|
||||
def rewrite(input)
|
||||
ast = Parser::Ruby22.parse( input )
|
||||
new_ast = process(ast)
|
||||
new_ast.to_s
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
37
test/parfait/test_interpreted.rb
Normal file
37
test/parfait/test_interpreted.rb
Normal file
@ -0,0 +1,37 @@
|
||||
# Test Parfait by parsing it and the tests, and interpreting it.
|
||||
# (Later also run on arm, much like the mains)
|
||||
#
|
||||
# The difference betwen the running parfait and compiled parfait is namespace.
|
||||
#
|
||||
# In the running interpreter (the one that runs the tests/compiler), Parfait is namespaced
|
||||
# to Parfait, because we define Class/Object/Hash/String etc. All that basic stuff that
|
||||
# is not namespaced in ruby and thus would clash in the running interpreter.
|
||||
#
|
||||
# Which leads straight to the point, that in the compiled code parfait is not namespaced.
|
||||
# Parfait files are actually without namespace, and the namespace is wrapped from the
|
||||
# outside, so we are good to just parse parfait files.
|
||||
#
|
||||
# But the tests are defined for the interpreter (also namespaced) and minitest is used,
|
||||
# so we can not just parse the tests. Instead we parse and rewrite the test (removing the
|
||||
# namespace and defining a mini mintest while we are there),
|
||||
# and then write a single main out. And interpret that.
|
||||
# For each test defined in Parfait.
|
||||
require_relative "helper"
|
||||
|
||||
module Parfait
|
||||
|
||||
class InterpretParfait < MiniTest::Test
|
||||
def setup
|
||||
parfait = ["object"]
|
||||
parfait.each do |file|
|
||||
ruby = File.read("./test/parfait/test_#{file}.rb")
|
||||
not_scoped = ParfaitRewriter.new.rewrite(ruby)
|
||||
#puts not_scoped
|
||||
end
|
||||
end
|
||||
|
||||
def test_any
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -16,5 +16,8 @@ module Parfait
|
||||
assert_equal @object.get_type , @object.set_internal_word(0, @object.get_type)
|
||||
end
|
||||
|
||||
def test_type
|
||||
assert_equal "Parfait::Type" , @object.get_internal_word( 0 ).class.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user