renamed program to boot_space, as in object_space at boot time. thats the way its going
This commit is contained in:
@ -13,7 +13,7 @@ require 'parslet/convenience'
|
||||
module Fragments
|
||||
# need a code generator, for arm
|
||||
def setup
|
||||
@program = Vm::Program.new "Arm"
|
||||
@object_space = Vm::BootSpace.new "Arm"
|
||||
end
|
||||
|
||||
def parse
|
||||
@ -24,9 +24,9 @@ module Fragments
|
||||
# and the last is wrapped as a main
|
||||
parts.each_with_index do |part,index|
|
||||
if index == (parts.length - 1)
|
||||
expr = part.compile( @program.context , @program.main )
|
||||
expr = part.compile( @object_space.context , @object_space.main )
|
||||
else
|
||||
expr = part.compile( @program.context , nil )
|
||||
expr = part.compile( @object_space.context , nil )
|
||||
raise "should be function definition for now" unless expr.is_a? Vm::Function
|
||||
end
|
||||
end
|
||||
@ -34,7 +34,7 @@ module Fragments
|
||||
|
||||
# helper to write the file
|
||||
def write name
|
||||
writer = Elf::ObjectWriter.new(@program , Elf::Constants::TARGET_ARM)
|
||||
writer = Elf::ObjectWriter.new(@object_space , Elf::Constants::TARGET_ARM)
|
||||
assembly = writer.text
|
||||
# use this for getting the bytes to compare to :
|
||||
#puts assembly
|
||||
|
34
test/fragments/test_class.rb
Normal file
34
test/fragments/test_class.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class TestClass < MiniTest::Test
|
||||
include Fragments
|
||||
|
||||
def test_base_class
|
||||
@string_input = <<HERE
|
||||
class BaseObject
|
||||
def _set_instance_variable(name , value)
|
||||
4
|
||||
end
|
||||
|
||||
def _get_instance_variable( name )
|
||||
4
|
||||
end
|
||||
|
||||
def _get_singleton_method(name )
|
||||
4
|
||||
end
|
||||
def _add_singleton_method(method)
|
||||
4
|
||||
end
|
||||
def initialize()
|
||||
4
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@should = [0x0,0xb0,0xa0,0xe3,0x2a,0x10,0xa0,0xe3,0x13,0x0,0x0,0xeb,0x1,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x40,0x2d,0xe9,0xa,0x30,0x42,0xe2,0x22,0x21,0x42,0xe0,0x22,0x22,0x82,0xe0,0x22,0x24,0x82,0xe0,0x22,0x28,0x82,0xe0,0xa2,0x21,0xa0,0xe1,0x2,0x41,0x82,0xe0,0x84,0x30,0x53,0xe0,0x1,0x20,0x82,0x52,0xa,0x30,0x83,0x42,0x30,0x30,0x83,0xe2,0x0,0x30,0xc1,0xe5,0x1,0x10,0x41,0xe2,0x0,0x0,0x52,0xe3,0xef,0xff,0xff,0x1b,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0x1,0x20,0xa0,0xe1,0x20,0x10,0x8f,0xe2,0x9,0x10,0x81,0xe2,0xe9,0xff,0xff,0xeb,0x14,0x10,0x8f,0xe2,0xc,0x20,0xa0,0xe3,0x1,0x0,0xa0,0xe3,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x70,0xa0,0xe1,0x0,0x80,0xbd,0xe8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20]
|
||||
@output = " 42 "
|
||||
parse
|
||||
write "putint"
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user