renamed program to assembler (to avoid clashes in vm)
This commit is contained in:
parent
990b4726ba
commit
fae0c1ab8c
@ -6,14 +6,14 @@ require "asm/string_literal"
|
|||||||
|
|
||||||
module Asm
|
module Asm
|
||||||
|
|
||||||
# Program is the the top-level of the code hierachy, except it is not derived from code
|
# Assembler is the the top-level of the code hierachy, except it is not derived from code
|
||||||
# instead a Program is a list of blocks (and string constants)
|
# instead a Assembler is a list of blocks (and string constants)
|
||||||
|
|
||||||
# All code is created in blocks (see there) and there are two styles for that, for forward of backward
|
# All code is created in blocks (see there) and there are two styles for that, for forward of backward
|
||||||
# referencing. Read function block and add_block and Block.set
|
# referencing. Read function block and add_block and Block.set
|
||||||
|
|
||||||
|
|
||||||
class Program
|
class Assembler
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@blocks = []
|
@blocks = []
|
@ -119,7 +119,7 @@ module Asm
|
|||||||
end
|
end
|
||||||
|
|
||||||
# length of the codes. In arm it would be the length * 4
|
# length of the codes. In arm it would be the length * 4
|
||||||
# (strings are stored globally in the Program)
|
# (strings are stored globally in the Assembler)
|
||||||
def length
|
def length
|
||||||
@codes.inject(0) {| sum , item | sum + item.length}
|
@codes.inject(0) {| sum , item | sum + item.length}
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require 'parslet'
|
require 'parslet'
|
||||||
|
|
||||||
require "asm/program"
|
require "asm/assembler"
|
||||||
require "elf/object_writer"
|
require "elf/object_writer"
|
||||||
require 'parser/composed'
|
require 'parser/composed'
|
||||||
require 'parser/transform'
|
require 'parser/transform'
|
||||||
|
@ -6,9 +6,9 @@ require_relative 'helper'
|
|||||||
# adc add and bic eor orr rsb rsc sbc sub mov mvn cmn cmp teq tst b bl bx swi strb
|
# adc add and bic eor orr rsb rsc sbc sub mov mvn cmn cmp teq tst b bl bx swi strb
|
||||||
|
|
||||||
class TestArmAsm < MiniTest::Test
|
class TestArmAsm < MiniTest::Test
|
||||||
# need Program and a block (see those classes)
|
# need Assembler and a block (see those classes)
|
||||||
def setup
|
def setup
|
||||||
@program = Asm::Program.new
|
@program = Asm::Assembler.new
|
||||||
#no ruby block given, ie need to add this block later by hand
|
#no ruby block given, ie need to add this block later by hand
|
||||||
@block = @program.block
|
@block = @program.block
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ class TestRunner < MiniTest::Test
|
|||||||
# execute
|
# execute
|
||||||
# check result ?
|
# check result ?
|
||||||
context = Vm::Context.new
|
context = Vm::Context.new
|
||||||
builder = Asm::Program.new
|
builder = Asm::Assembler.new
|
||||||
compiled = tree.compile( builder , context )
|
compiled = tree.compile( builder , context )
|
||||||
puts compiled.inspect
|
puts compiled.inspect
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ require_relative 'helper'
|
|||||||
class TestSmallProg < MiniTest::Test
|
class TestSmallProg < MiniTest::Test
|
||||||
# need a code generator, for arm
|
# need a code generator, for arm
|
||||||
def setup
|
def setup
|
||||||
@program = Asm::Program.new
|
@program = Asm::Assembler.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_loop
|
def test_loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user