Commit Graph

453 Commits

Author SHA1 Message Date
Torsten Ruger
b2339dc330 fix address nil values 2018-08-30 16:38:00 +03:00
Torsten Ruger
dc12c1d70b add the addresses from labels as constants 2018-08-29 21:06:29 +03:00
Torsten Ruger
ea7f3c9653 remove the last_object from chain
also tried to keep the first around as was done in space
partially to not have to add the consrtants seperately
didn't work, as chain gets broken
also this has to be redone anyway
2018-08-29 21:05:54 +03:00
Torsten Ruger
c983dcf0eb move return address generation to factory
removes the list from space
adds a ReturnAddress factory instead
and uses these throughout
2018-08-29 21:02:49 +03:00
Torsten Ruger
f993ccefe3 litte bit of docs 2018-08-24 18:49:44 +03:00
Torsten Ruger
71ab369c71 use factory to generte intergers in space
start with just integer factory in space
change all the hand-out code
still #14
2018-08-24 18:49:21 +03:00
Torsten Ruger
d396da16e3 start with #14 by implementing factory
page was maybe a too low level name
pages may be the unit of the syscall, but after that objects desolve (maybe later to be added on from different pages)
Factory has the job of handing out a new instance of a type
it keeps a freelist for that and a reserve
2018-08-23 19:55:06 +03:00
Torsten Ruger
9687d6611f avoid adding risc instructions twice
that causes loops in the chain
infinite loops in the code that are hard to debug
closes #11
2018-08-19 17:29:04 +03:00
Torsten Ruger
f85fe8a2cb fix bug in slot_load and definition
move parfait helper for reuse
2018-08-19 15:36:51 +03:00
Torsten Ruger
57dc6c45bb remove the code_builder
this is core of #11
rename compiler_builder to just builder
and change all builder uses to use that
some test change as code is not returned anymore
2018-08-19 13:16:07 +03:00
Torsten Ruger
da9dc30c20 move dynamic_call to builder
no change of test, great
also remove some duplicate code that was hanging around in method_compiler
2018-08-16 10:43:41 +03:00
Torsten Ruger
ce157ffa94 change block_yield to_risc to use builder
only changes the order of two instructions
2018-08-16 08:58:49 +03:00
Torsten Ruger
1dabe0fda1 finish the idea behind #8, conditionally creating variables
by using space? , the ? makes for conditional creation of the variable
This is especially useful for constants (ie space)
2018-08-15 19:59:17 +03:00
Torsten Ruger
01752aab05 remove the last use of an add_xx function, closing #9 2018-08-15 19:37:03 +03:00
Torsten Ruger
43fa7ccbcc redid div10 with builder
div10 is right at the edge of what can be understood
no matter the (assmbler) syntax
2018-08-15 19:30:40 +03:00
Torsten Ruger
252ae6de72 finally get rid of the fixme in div10
create (load/reduce) the int once and transfer.
Save a cruicial 2 instructions

Also expanded the variable name possibilities with _self, __const , _1 and _2
2018-08-15 18:18:21 +03:00
Torsten Ruger
15337e10be move putstring to use builder 2018-08-15 17:52:21 +03:00
Torsten Ruger
e953cc90d5 remove some more add_xx functions
also load labels by dsl now
2018-08-14 20:24:48 +03:00
Torsten Ruger
520dc7b41f remove ad_transfer in save_message
towards removing all add_
change to set_builder and chaining in reg values
2018-08-14 20:08:58 +03:00
Torsten Ruger
37461a1727 add the ! syntax to create variables in builder, fix #8
now a variable has to be created before being used
thus it is save to develop contracts where a certain name
must exist in the scope
Maybe the syntax starts getting a bit weird, but at least the ! is a common symbol in ruby
2018-08-14 19:39:46 +03:00
Torsten Ruger
0bf008b351 bit of documentation 2018-08-14 11:23:19 +03:00
Torsten Ruger
fb54d68020 redo restore after syscall with builder 2018-08-13 18:48:54 +03:00
Torsten Ruger
55bc9c5273 rewrite new_int with builder 2018-08-13 18:02:34 +03:00
Torsten Ruger
fee9e261a5 still some names that needed changing 2018-08-12 14:48:20 +03:00
Torsten Ruger
3d113b4d83 fix more of the changed names
add a few self.
2018-08-12 13:10:44 +03:00
Torsten Ruger
66e0d4ae26 cache index resolution
resolve once and reuse
also use non checking version of get/set
as index per definition must be ok
This creates some speedup, but mostly avoids some weird hang in Thread::Queue.pop for many seconds
2018-08-12 13:09:34 +03:00
Torsten Ruger
84de400529 some test change because of renaming
next is a keyword, can't be used as instance writer
fake_memory gets the pobject for debug
2018-08-11 19:17:20 +03:00
Torsten Ruger
e6df473647 changing the adapter to have fake memory for every object
Before instance variables were used to store the actual data
While this worked it was a double mental loop and (more importantly) did not allow the same memory access
Ie, in the interpreter the types for args had to be set correctly
But they don't need to be until we walk the list, when we can get the types from the method.
In short, now the fake memory may be used as memory, by indexing into it

We now have to use attr reader/writers that map to the fake memory
And while this is possible, it means a lot more self. than i would like
Also the compiler whill have to undo those attr to instance acess at some point
2018-08-11 19:13:09 +03:00
Torsten Ruger
d74e9c2c40 removed some obsolete builder helpers
cleaner code with dsl,
just div10 undone
2018-08-09 21:10:05 +03:00
Torsten Ruger
99a95d40a6 also redid the get/set internal byte with builder
had to pimp register value to use a semblance of the dsl
using <= for bytes and << for words
2018-08-09 20:16:55 +03:00
Torsten Ruger
7002956e81 redid get_set internal byte with builder
trying to change style, get rid of some of builders functions
2018-08-09 20:15:52 +03:00
Torsten Ruger
0d52b620ed redid integer comparison with builder
had to add some helpers to builder
2018-08-08 20:53:06 +03:00
Torsten Ruger
fc6aa4e28b rework operator with builder 2018-08-08 15:49:47 +03:00
Torsten Ruger
78466090b3 add reduce_int and fix bug
hardcoded operator, buh
reduce_int to avoid that long constant
2018-08-08 15:49:07 +03:00
Torsten Ruger
6200a35562 add shortcut for class_name
for when type is not set
2018-08-08 12:02:59 +03:00
Torsten Ruger
71a7161200 redid div4 with builder 2018-08-08 12:02:24 +03:00
Torsten Ruger
c63e55c2bc add an operator function
to be able to use the builder more
also add ability to load fixnums (for the int functions)
2018-08-07 20:48:36 +03:00
Torsten Ruger
595e032edf add function_return helper to risc_value
create a function_return from within builder
2018-08-06 13:03:33 +03:00
Torsten Ruger
c9d8f750e5 extend type inference for dsl
and finally test it
2018-08-06 10:11:12 +03:00
Torsten Ruger
5346077a72 use the return jump to jump to the return sequence
thus every method only has one exit
should make multi return messages smaller
especially when we have escape analisis
(maybe will help with inlining too)
2018-08-02 17:36:39 +03:00
Torsten Ruger
4b4528abb2 propagate constants from block_compiler up
up to method_compiler, where they are collected by mom_compiler
(and included in binary)
2018-08-01 16:27:34 +03:00
Torsten Ruger
04bcfea8ce fix scoping of blockcompiler
Was accessing caller scope, but must use caller's caller as the yield itself is a call.
2018-07-31 18:00:42 +03:00
Torsten Ruger
9c6a099cde block test
working on return semanitcs
(still avoiding the implicit return)
2018-07-30 14:10:24 +03:00
Torsten Ruger
165036ea39 misc 2018-07-30 10:26:47 +03:00
Torsten Ruger
2dc03f8d1b push the callable into the callable compiler
thus generalizing for .callable access
keep block and method aliases for destinction in derived classes
2018-07-30 10:26:11 +03:00
Torsten Ruger
285a88b59f generalize assemblers to use callables
not just methods,  they are almost the same anyway
2018-07-30 10:23:42 +03:00
Torsten Ruger
4055709529 push the name down into callable
blocks need a name too
if just for debug, and stacks
2018-07-30 10:21:43 +03:00
Torsten Ruger
1cb07a4164 block arg access was off by one 2018-07-27 12:16:06 +03:00
Torsten Ruger
e1d5592c55 fix boot to include blocks correctly 2018-07-27 10:48:45 +03:00
Torsten Ruger
f5c284b3a0 bring the blocks down to mom level
reusing message_setup, but adding yield specific instructions
2018-07-24 11:35:49 +03:00
Torsten Ruger
d80ef4bf4e store method, not name, in message
changes the calling and thus too many test
2018-07-22 22:29:32 +03:00
Torsten Ruger
3c1137066b more block tests reveal a compiler bug
copy/paste, args twice in switch
2018-07-18 10:13:19 +03:00
Torsten Ruger
ff8b95f21a get block resolution to use the extra
block_compiler puts in the extra, that we get out when resolving the type
Thus block args work, though only by assuming direct call
2018-07-17 10:37:33 +03:00
Torsten Ruger
280ea8a8c4 remove resolve_to_register
which was, quite simply, from another era when more than message was pinned
2018-07-16 19:19:49 +03:00
Torsten Ruger
73645e1507 rename resolve_type to infer_type
as we go from a symbol to a type, more or less by convention
also remove the compiler from there and other not used cases
No tests change, good refactoring
2018-07-16 19:17:57 +03:00
Torsten Ruger
4cc04787e9 remove Risc.resolve_to_index
mostly by using better typed registers,
which cleans up the code where it was used
2018-07-16 19:00:04 +03:00
Torsten Ruger
29363e7f72 split compilers resolve_type into the three possibilities
cleaner code, though temporary it shifts some dirt
into the index method. up next
2018-07-16 12:03:40 +03:00
Torsten Ruger
3343017dba move type resolution to compiler
from risc_value.
also unite mock compilers
2018-07-16 11:46:18 +03:00
Torsten Ruger
e3673e579c pass extra info into register init, not just value
extra info may be hash, maybe just type info
2018-07-16 11:23:09 +03:00
Torsten Ruger
3bc85805a4 must pass registers to slot_to_reg and reg_to_slot
as they are typed, those functions don't resolve on Risc, but the register type
miscother changes from previous commits
2018-07-15 16:30:50 +03:00
Torsten Ruger
f31d22d901 use real type in register, not symbol
this has some more consequences, upcoming
2018-07-15 15:16:12 +03:00
Torsten Ruger
a71a6d34fb use message reg not message
for upcoming change
2018-07-15 15:14:38 +03:00
Torsten Ruger
58c7294abd finish the loop in slot_load
thus rewrite of that old nested if thing is done
2018-07-14 11:04:21 +03:00
Torsten Ruger
61c840c023 start to move slot_load code to register_value
the iea is to iterate through register_values while reducing the slot_load to a number of Slot_to_regs
wip
2018-07-13 21:56:55 +03:00
Torsten Ruger
21009b0e9b delegate resolve to compiler when needed
and forgotten space test
2018-07-13 21:55:27 +03:00
Torsten Ruger
a095515b0e new get_type_by_class_name helper for space
sorely needed, with 36 occurences replaced
2018-07-13 21:50:40 +03:00
Torsten Ruger
27a142f2a3 use compiler base class for blocks too
can now go to mom level and add
test harness still looks overly complicated, but works
first block tests at mom level
2018-07-10 22:03:32 +03:00
Torsten Ruger
a3e758357c extract base class from method_compiler
to be used for blocks too
2018-07-10 22:02:11 +03:00
Torsten Ruger
edea9ac080 makeing the method of the compiler more or less private
in preparation for using the same code for bocks
2018-07-09 19:32:17 +03:00
Torsten Ruger
63b55f2aa4 refactor a bit for upcoming delegations
must get method to be private
more tell, not ask
2018-07-09 18:16:51 +03:00
Torsten Ruger
4ac89ece66 start delegating scope matters to the compiler(s)
slot_type_for to return the slot way to access variable
this is off course version 0.0.1 alpha, no types are checked or errors handled
2018-07-09 17:53:56 +03:00
Torsten Ruger
dd544214b3 start with block_compiler
as a copy of method_compiler
re-merge later, when we know what's needed
2018-07-09 16:48:23 +03:00
Torsten Ruger
0d900de695 block creation and insertion with correct types 2018-07-07 22:42:00 +03:00
Torsten Ruger
2f07cc34f3 add parfait block 2018-07-07 15:50:43 +03:00
Torsten Ruger
9005513368 rename typed_method to callable_method
seems to make the essence clearer
also extracted base class
2018-07-07 09:11:09 +03:00
Torsten Ruger
acd5cd8f30 rename for_type to self_type
and split a base class off TypedMethod
2018-07-06 20:01:17 +03:00
Torsten Ruger
d8b58d8da6 fix inital main (again)
stop even compiling a fake main if a real exists (in builtin)
previous version was still buggy: using builting methods types (especially locals) even comiled version had different
2018-07-04 09:17:30 +03:00
Torsten Ruger
6f936f190d misc to_s and small fixes 2018-07-04 08:28:29 +03:00
Torsten Ruger
e099014d63 fix dunamic jump in interpreter and misc 2018-07-03 19:15:36 +03:00
Torsten Ruger
bb1d1495db fix constant propagation through the layers
so they can end up in the binary
2018-07-03 10:12:22 +03:00
Torsten Ruger
56f2742e89 fix code listener logic bug
next's position was only updated initially
previous logic relied on pushing everything long rightly
but it wasn't right, and no harm in setting position twice,
as events only fire if there is real change
2018-07-02 23:03:00 +03:00
Torsten Ruger
a1197fb70c interpreter tests working again 2018-07-02 17:29:26 +03:00
Torsten Ruger
6af651a886 text writer working
adjusted ordering as psoitioning, ie
methods in order of the assemblers of the linker
(not the object space)
2018-07-02 17:05:02 +03:00
Torsten Ruger
474cd4b348 linker and collector test work again
had to give space a fixed number of addresses
2018-07-02 16:19:01 +03:00
Torsten Ruger
6a4c90e2bd fix the cpu_init for linker
cpu_init still translates from risc_init
but since interpreter is a platform risc_init is a private thing
and the cpu_init does not need to be lazily created, so it's done in the init
2018-07-02 15:51:50 +03:00
Torsten Ruger
1132309f6a unify space collection attribute naming
currently space is still acting as a sort of memory manager.
For proper linking, all objects must be reachable from space, hence the plural versions like messages and addresses (even they are instances, it is the list that is important)
To dish out instance to use, the head must be kept, ie next_XXX for intergers, return addresses and messages
2018-07-02 15:49:51 +03:00
Torsten Ruger
07a154be70 code listener now get platform explicitly
used to grab it from global machine.
Now passed in from linker
tests fixed accordingly
2018-07-02 09:39:07 +03:00
Torsten Ruger
8952b39446 linker goes through assemblers, not space
used to traverse all methods in space
now "just" use the passed assemblers, which usually should be compiled and builtin (but for testing . . .)
tests fixed accordingly
2018-07-02 09:37:58 +03:00
Torsten Ruger
c6f0dc636d platform helper 2018-07-02 09:36:29 +03:00
Torsten Ruger
f4b1290e58 position tests working 2018-07-02 09:35:57 +03:00
Torsten Ruger
22408b86c6 return the linker from mom_compiler
linker holds assemblers
assemblers come from method compilation
and so the layers come into focus
2018-07-01 21:51:48 +03:00
Torsten Ruger
5f2a256608 fix platform derivation and some tests 2018-07-01 21:27:27 +03:00
Torsten Ruger
c947c27a14 clean up booting
many machine boot became obsolete
or just neede parfait to boot
actual linker functionality pending
2018-07-01 14:12:42 +03:00
Torsten Ruger
e75aef933d have to pass constants around now
as they are not global anymore
2018-07-01 14:11:29 +03:00
Torsten Ruger
e10092a4be rename machine to linker
even work is not quite finished, but helps root out offenders
(needless to say this is wip, deep red wip)
2018-07-01 13:45:14 +03:00
Torsten Ruger
57fc67ddf6 move address list to object_space
where i guess it should have been from the start
2018-07-01 13:43:53 +03:00
Torsten Ruger
35b10c46a3 adds the risc instructions to the compiler
since they are not in the method anymore
2018-07-01 11:59:52 +03:00
Torsten Ruger
1505df894a remove translation
from machine, which is quickly becoming a linker
2018-07-01 11:58:06 +03:00
Torsten Ruger
1a97408e22 return compiler, not generated mom
does make the tests more verbose, but the code cleaner
2018-07-01 11:57:17 +03:00
Torsten Ruger
2d83473d74 add assembler
getting the layers better
2018-07-01 11:53:18 +03:00
Torsten Ruger
05669065ca back to method_compiler
it is what it is
2018-06-30 23:26:28 +03:00
Torsten Ruger
91a99b1239 let boot_functions return the compilers
methods are still added, but this is a good step to removing the risc/cpu level from the methods
2018-06-30 23:16:17 +03:00
Torsten Ruger
208b98d709 start to move translate code 2018-06-30 22:53:32 +03:00
Torsten Ruger
46d8f5002f hoist parfait boot out of the machine boot 2018-06-30 00:39:23 +03:00
Torsten Ruger
ae35fed0ab fix list to expand
prevously fixed max length list
now expanding on demand, using next
quite like binary_code, a pattern is emerging
2018-06-29 20:58:59 +03:00
Torsten Ruger
6bd01fd55f rename method_compiler
in line with other compiler XX_Compiler being the compiler for that layer
remove type from compiler as it is in method available
2018-06-29 14:48:52 +03:00
Torsten Ruger
114dc95b60 move parfait boot into parfait
and out of risc
2018-06-29 14:36:11 +03:00
Torsten Ruger
e6f01748ff move adapter stuff around 2018-06-29 14:26:25 +03:00
Torsten Ruger
86b1edb40c add seperate builders
remove if with polymorphism for different builders
(easier to understand by naming)
2018-06-29 13:27:57 +03:00
Torsten Ruger
3dffebed3f rename a bit 2018-06-29 13:03:19 +03:00
Torsten Ruger
d50893bb0f rename risc_value to register_value
almost to register, but it still carries that value
2018-06-29 11:39:07 +03:00
Torsten Ruger
606c7bf906 remove booted flag
just boot if needed
2018-06-29 11:36:14 +03:00
Torsten Ruger
f1b09ac58d move builtin boot to builtin module 2018-06-29 11:23:26 +03:00
Torsten Ruger
ce79617875 fix the exit sequence
was returning wrong register (1, not 0)
also saving the message for test, which changes order as the return value destroys the message
2018-06-19 19:52:06 +03:00
Torsten Ruger
5f7683efcf pass return integer back out through exit
for testing of binaries later (and off course general correctness)
Some tests were using the fact that the interpreter was used, changed those to return ints rather than strings
2018-06-19 18:55:47 +03:00
Torsten Ruger
db459fcd3d fix label loading in arm
was still loading the integer address
instead of the return address's address
Hello World working
2018-06-19 17:35:00 +03:00
Torsten Ruger
956c2ebe54 make arm use branch_lsteners 2018-06-19 10:51:03 +03:00
Torsten Ruger
046617f8dc add branch listener functionaliy
have to store the branches and loop again as labels
dont neccessarily have positions yet
2018-06-17 22:25:38 +03:00
Torsten Ruger
3298651238 split create_binary into two phases
Which gives instructions a chance to check everything
and in Arms case check the constant loads/ instruction adding
So that during assembly no more change happens (and we don't have to reassemble)
2018-06-17 13:53:17 +03:00
Torsten Ruger
7543236f4f objects didn't get positions
positions.empty? was wrong check
2018-06-16 10:58:54 +03:00
Torsten Ruger
698c845297 seperate position create and register
many test fixes
2018-06-15 22:00:49 +03:00
Torsten Ruger
9c93b38b8f crete positions while collecting objects
clear two phase lifecycle for positions
always created invalid and set later
new does not auto add to cache
but create and get_or_create do
2018-06-15 21:54:21 +03:00
Torsten Ruger
2c765c8f14 rename the objects accessor
and move to object keys, not object_id
2018-06-15 09:18:39 +03:00
Torsten Ruger
3cc9175efa start BranchListener
but on hold, since it needs positions before we have them
Must create them during collection phase
2018-06-14 21:29:34 +03:00
Torsten Ruger
5ec235d049 fixes outstanding misc, All green
Well. it's been a while, positioning is fixed (again)
apart from the upcoming BranchListener
2018-06-10 13:19:55 +03:00
Torsten Ruger
e1683938ed fix label positioning bug
where a label at the end of a binary code resulted in the
label actually taking up a position, instead of sharing it with it's next
2018-06-10 13:18:56 +03:00
Torsten Ruger
0513cd504f update return address in label
so return jumps go to the right address
2018-06-10 09:15:57 +03:00
Torsten Ruger
c7ad1d98ca introduce the LabeListener to move instructions along when first code position changes 2018-06-09 22:13:43 +03:00
Torsten Ruger
ec1d38f5a6 reimplement instruction listeners with indexes
easier to understand, as indexes map to Binarycode indexes, and can thus later be used to assemble directoy into the  code
Almost no change in tests (now only multiples of 4 addresses allowed)
2018-06-09 17:41:39 +03:00
Torsten Ruger
cf94227b2c fix code init bug
where initial pos wasnt propagated
2018-06-09 09:16:23 +03:00
Torsten Ruger
e4b4551acf minor simplification 2018-06-09 08:13:37 +03:00
Torsten Ruger
ad3040a846 add position_chaning to event interface
by reacting to the change _before it happens, we can move any BinaryCode out of the way

So when Instruction are inserted and code gets inserted, we don't need to set up the correct listener explicitly (which is tricky across mathods and changing chains), but instead just move anything that is in the way along
2018-06-09 08:10:41 +03:00
Torsten Ruger
5815d32bde make the instructions jump over the BinaryCode end 2018-06-07 19:27:44 +03:00
Torsten Ruger
2d218bbc48 work on jump insertion continues
Now registering CodeListener instead of PositionListener
Also instead of on the previous, in itself, which is simpler
and allows to react to insertion at end
2018-06-07 19:26:02 +03:00
Torsten Ruger
7fa8397b56 insertion pushes, split position tests 2018-06-06 10:19:18 +03:00
Torsten Ruger
c22aff4c4f start on insertion events and handling 2018-06-06 10:00:07 +03:00
Torsten Ruger
4789b63fcb fix the gapping of instructions
so last binary stays empty and new starts at 8
2018-06-06 01:16:00 +03:00
Torsten Ruger
4ab6d62acf small arm fixes etc 2018-06-06 00:53:41 +03:00
Torsten Ruger
d7b3368b28 fix some pesty errors
need to fix instruction overlap beofre interpreter starts again
2018-06-05 19:05:12 +03:00
Torsten Ruger
8d953a619f propagate instruction positions
still overlapping onto binaries, but a start
2018-06-05 18:11:25 +03:00
Torsten Ruger
f35ee6425a renaming and test fixing 2018-06-02 23:48:12 +03:00
Torsten Ruger
1d1c7105b4 introduce some helper methods 2018-06-02 23:02:59 +03:00
Torsten Ruger
c2d450f779 fold position module and object position
simpler that way, aslo code is moving to listners
2018-06-02 21:59:41 +03:00
Torsten Ruger
24f6e30b54 start on redoing instruction positions
using insruction listeners (wip)
2018-06-02 21:20:15 +03:00
Torsten Ruger
3bc35c2275 rework binary code positioning setup
dependency chain set up explicitly.
Next have to react to events correctly
2018-06-02 17:29:38 +03:00
Torsten Ruger
91c7903848 start simple with code listner 2018-06-02 16:34:44 +03:00
Torsten Ruger
aa6707337a positioning wip 2018-06-02 16:12:01 +03:00
Torsten Ruger
46fbfb7101 adds the simple object dependency
where the next object is dependent on the previous one
and just behind it, the padded_length away
2018-05-31 20:41:04 +03:00
Torsten Ruger
21a9c56ba9 change position event code to use util
general purpose event fireing
can then be used for several event types
2018-05-31 19:05:53 +03:00
Torsten Ruger
2544bc5a85 move position module to folder 2018-05-31 19:01:10 +03:00