Commit Graph

2254 Commits

Author SHA1 Message Date
Torsten Rüger 1eb6430880 last fixes for cc
seems like setup had just worked by chance and change broke that.
2019-08-23 19:22:27 +03:00
Torsten Rüger 89f32ed74a Changing the call setup and return to be more efficient
Now we are using a statically linked list of messages. This will not work with procs, but that can be solved then.

Previous (wrong) thinking was that because of procs messages have to be allocated for every call. This was too slow, and not neccessary
2019-08-23 15:30:27 +03:00
Torsten Rüger 8ed013c2b9 Change Locals in calling convention
Just like the args, locals are now inlined into the Message.
Message is off course bigger, but as they are created at compile time, that hardly matters
Some programs did get somewhat smaller, especially with both changes, but not super much
2019-08-23 10:23:01 +03:00
Torsten Rüger ec1e8c8f3a Fix risc layer from cc changes 2019-08-23 10:20:39 +03:00
Torsten Rüger 7ca3599c5a Fixed all after changing argument handling
arguments are now fully inlined into the message
locals next
2019-08-22 23:10:29 +03:00
Torsten Rüger 017e7e2971 fix most of mom from calling changes 2019-08-22 22:56:44 +03:00
Torsten Rüger 0c49612e5e vool working after message change 2019-08-22 21:24:02 +03:00
Torsten Rüger 0a1b05b2ee Inline arguments into message
thus removing indirection for access
does affect rather much, several commits
2019-08-22 17:55:19 +03:00
Torsten Rüger 5dc8c046e7 increase binary_code size to 32
save a few jump, adds some size to binary
16 just seemed kind of small
2019-08-22 12:26:40 +03:00
Torsten Rüger 064bb2f90f Fix compilers link
link command varies on systems, hmm
2019-08-19 19:13:51 +03:00
Torsten Rüger 57b0ad2c32 Fix super as statement
Super is a statement, a send really.
Not an expression (as maybe in c++)
The actual implementation will be a bit tricky, like raise, a bit of stack walking, but not impossible. Still, later
2019-08-19 18:48:13 +03:00
Torsten Rüger 0e694a38f7 Implicit returns for class methods
gets us parsing of parfaits second file data_object
2019-08-19 15:56:15 +03:00
Torsten Rüger a722a4c285 Move vool block compilation into constant generation
When the lambda is passed as argument, it must be moved. This triggers the generation of a corresponding parfait object (as before, and as for other constants) but now also triggers the code build. The code being the constant as it were
Also some more name fixes from renames
2019-08-19 14:33:02 +03:00
Torsten Rüger 3ddf2e3837 Redoing ruby block conversion
Since the block is actually a constant, it does not need assignment or special hoisting
Just use the send and stick the lambda in as last arg
2019-08-19 14:23:55 +03:00
Torsten Rüger f87526f86f Renaming Vool exppressions rightly
Class, Method and Lambda (was block) are expressions.
Just making things clearer, especially for the blocks (ahem, lambdas) is matters.
wip
2019-08-19 11:33:12 +03:00
Torsten Rüger ae16551ed0 Rename Vool Block to Lambda
Making the distinction clearer
Some fixing of previous (wip)
2019-08-19 10:40:22 +03:00
Torsten Rüger 02807cf6f9 Rename Block to RubyBlock at Ruby level
The parser presents the whole call that defines the block as a block. And so does the Ruby layer, as we don't want to do processing in ast.
Just making it clearer, also Vool:: block will have to be renamed
2019-08-19 10:31:11 +03:00
Torsten Rüger ee8927b059 Fix slot access for constants
Type access is allowed for any object, including constants.
Needed for parfait
2019-08-18 20:35:01 +03:00
Torsten Rüger c9d77a29b2 Running tests on binary through qemu (system, no ssh) 2019-08-18 12:39:23 +03:00
Torsten Rüger 15d1c07a1c Remove dead code
some copy paste in creating full mom layer left dome unused (untested) 
code
thanks to code climate stats
2019-08-18 10:19:52 +03:00
Torsten Rüger 5a43cbff15 Fixing tests for implicit return
previous commit affected rather many test, as the implicit returns add extra instructions
Also added some explicit returns, so as not to test the return logic too much. return (ie return nl) is a knonwn 3 risc operation.
2019-08-17 23:29:42 +03:00
Torsten Rüger 32f908c127 Adding simple implicit return
Ruby return semantics are easy to grasp, not so easy to code. So many cases.
Added support for common cases, return const/variable or call.
2019-08-17 23:27:55 +03:00
Torsten Rüger 4c76ff3388 Remove Padded module
Parfait was depending on it, ie it created a dependency out of Parfait. But Parfiat needs to be self contained.
Moved 2 methods into parfait object, and resolved single call from text_writer to third.
2019-08-17 21:07:07 +03:00
Torsten Rüger ae7f31381b Fixing self type creation
When compiling a classs, we pick up all instance variables.
Now that conditions and returns can be calls, that was broken, now fixed
2019-08-17 15:58:27 +03:00
Torsten Rüger d3f3c91ae5 Fix all but one test
Riples upon riples. The one left looks like the genuine article
2019-08-16 21:43:54 +03:00
Torsten Rüger 7c91a08d5b Fix vool assignments after call rework
also small fix for if and return, as they need to execute sneds and yields (not just sends), so testing for Call not SendStatement
2019-08-16 20:39:08 +03:00
Torsten Rüger e6c30d98fb Fix if statements hoisting, now that send is working
Same same, just have to remembe to actually execute the condition if it is a send
Having send a possible expression, removes one tmp variable and associated move, for a little extra work.
Next return and assign (rest)
2019-08-16 18:42:57 +03:00
Torsten Rüger dee1e24c28 Fix ruby receiver to vool
for chained calls to be normalized correctly
2019-08-16 16:05:45 +03:00
Torsten Rüger c213cf874b Fix ruby normalising to_vool
So that vool layer never has complex conditions or returns
Start with while, next if, return and assign
2019-08-16 14:20:06 +03:00
Torsten Rüger 84b9811e55 Fixing ruby send with arguments
When send has complex args, mostly more sends, we hoist those out and pass created temporary variables
2019-08-15 21:30:36 +03:00
Torsten Rüger 31ae0a9670 Add support for unless
ifs without a true branch would crash before
Somewhat more verbose but unified
2019-08-14 22:24:35 +03:00
Torsten Rüger d6c38d15ba Fix calling unknown methods
Before, when the type was determined, it was assumed that the method can be resolved. But off course tis is not true, as methods may be defined later in the file.
Two solutions for that. One could  (and should) define all methods and only then start to compile. Thus having the type safety.
Or (as now) make a dynamic call and let it fail at runtime.
2019-08-14 14:59:54 +03:00
Torsten Rüger b2260d856d And we are green again
After having over 600 failing tests at one point, this does feel good.
Even better, most of the risc/interpreter tests where i didn't change anything came gree without changing the tests. ie we have binary compatibility.
2019-08-14 11:11:26 +03:00
Torsten Rüger c13a8ceb11 all of mom and vool
with working block tests this time
2019-08-13 20:35:27 +03:00
Torsten Rüger 155c042009 Fix forgotten block compiler
Especially on the way down to risc
2019-08-13 19:32:17 +03:00
Torsten Rüger 8036b23593 Fixed more disabled tests 2019-08-13 11:14:36 +03:00
Torsten Rüger aaf169ad8d Fixed almost all but Interpreter
150 only failing, seems only 1 bug though
and one in linker
2019-08-13 00:13:29 +03:00
Torsten Rüger 9474932320 fixing risc collection tests 2019-08-12 16:12:17 +03:00
Torsten Rüger 9a2716280c Extracting the mom instruction from builtin modules
Since they were embedded at first (easier copy/paste) they now got own files, like their brethren
also mini tests for each instruction , nice start
2019-08-12 13:16:15 +03:00
Torsten Rüger fa0aa30386 Move builtin wholesale to Mom
Since Builtin generates risc, just like mom instructions, it was a design mistake to put builtin into risc in the first place. Now that borders are coming more into focus, it make much more sense to have the builtin in mom.
In fact the instructions should be moved out and a seperate invocation mechanism used , so functions can be parsed, not generated (wip)
2019-08-12 12:38:29 +03:00
Torsten Rüger a4b6f29834 Booting functions again and send test
both class and normal sending tests at vool / mom level
2019-08-12 11:57:32 +03:00
Torsten Rüger 2326081161 Now booting all original methods
Just need to refactor now
2019-08-12 11:31:47 +03:00
Torsten Rüger 91ddae2251 Start to convert integer operations
All apart from operators, which are its own thing
2019-08-12 11:08:09 +03:00
Torsten Rüger 97488c4e5b Transform builtin word functions
according to same schema
2019-08-12 10:45:07 +03:00
Torsten Rüger 3282e0ae06 transformed object builtins 2019-08-11 20:36:10 +03:00
Torsten Rüger 0725f02e9a starting to fix builtin
start at Object get_interna_word
using the pattern to replace the whole risc method with a single mom instruction. Copying the original risc code into the instrucitons to_risc
also adding some very basic tests
2019-08-11 14:31:00 +03:00
Torsten Rüger 0b59c95218 more test fixes and more to do 2019-08-10 21:59:31 +03:00
Torsten Rüger 213938075f fix most mom and risc apart
apart from things involving builtn, which is not yet conceptually solved (as it codes risc, not mom)
2019-08-10 21:30:00 +03:00
Torsten Rüger d5f89a4979 compile from mom compiler to risc 2019-08-10 12:42:47 +03:00
Torsten Rüger 5994cd3276 starting on mom to risc
some docs too
2019-08-08 12:19:27 +03:00
Torsten Rüger d5625a70d7 fix a whole bunch of vool to_mom
All but those requiring boot functions
2019-08-07 15:09:26 +03:00
Torsten Rüger 1237e079f7 Some vool starting to work again
disabling some rubyx compiler tests
2019-08-07 12:06:06 +03:00
Torsten Rüger 5d1d485565 move mom instruction up one
just like the risc one, also some basic tests
2019-08-06 20:44:39 +03:00
Torsten Rüger 66c2adda20 Copy risc compiler stuff to mom
Start to separate the layers. 
wip, just checkin in to see the following changes better
2019-08-06 18:33:27 +03:00
Torsten Rüger d3ed29520e Some docs 2019-08-06 17:42:15 +03:00
Torsten 3c0ba4f2ab Merge branch 'master' into new_mom 2019-08-01 09:20:34 +03:00
Torsten 7daf015ed2 small refactor 2019-08-01 09:20:08 +03:00
Torsten ab87806d08 fixes #26
only recurse to 1k
then come up for air an go again.
Should allow for 1M objects on a 2k stack (previously exceptions at 3.6k)
2019-07-28 16:42:40 +03:00
Torsten 74f3420d45 added execute command and options
execute to compile and run
options to pass parfait factory levels in (as no gc)
2019-07-25 22:36:51 +03:00
Torsten 14c965360d a basic interpret command for cli
part of the benchmark effort
determine amount of objects
2019-07-25 21:23:55 +03:00
Torsten fdb940e43f stashing 2019-07-22 15:21:16 +03:00
Torsten Ruger 1391667f6c still doing attr_reader, but closing #25
cattr still missing, but only one occurence. Later.
2019-03-07 11:00:18 +02:00
Torsten Ruger 5ed6a07083 better test for attr
still #25
2019-03-07 10:47:48 +02:00
Torsten Ruger 04720d4950 implement attr setter correctly
part of #25
still need to do for list and attr_reader
2019-03-06 11:21:09 +02:00
Torsten Ruger b4b1e6e13b start rewriting for parfait #25
just some infrastructure for now.
2019-03-05 20:36:40 +02:00
Torsten Ruger 11c5389e24 Fix if logic error
ifs may have an empty true block
Especially for unlesses thet is normal, so allow
2019-03-05 20:30:24 +02:00
Torsten Ruger 9bd2195a15 use cattr instead of metaclass
so we can catch it in the compiler, like also attr
define cattr in adapter, no change in tests !
2019-03-04 19:56:53 +02:00
Torsten Ruger 8d4eab72bf update parser to use 2.6
was choking on &. syntax
improved error reporting slightly
2019-03-04 19:00:47 +02:00
Torsten Ruger fb89c01681 clean up test option handling 2019-03-04 10:24:08 +02:00
Torsten Ruger eec72a9fca Successfully interpret class methods
just about closes #24
2019-02-27 09:48:21 +02:00
Torsten Ruger 461a6933c6 better tests for class sending
still #24
2019-02-23 18:17:26 +02:00
Torsten Ruger 0ebb8e31c6 to_s for parfait list 2019-02-17 18:16:19 +02:00
Torsten Ruger e430701645 Using MetaClass to compile class methods into
still #24, still wip
2019-02-17 14:37:50 +02:00
Torsten Ruger 3db7707614 Get a basic MetaClass going
Does get created in new, but not in boot.
Also not yet used in compiling
2019-02-16 23:24:16 +02:00
Torsten Ruger 2fbea82039 bring class methods down to mom
not functionally correct, still compiling into class, not metaclass
part of #24
2019-02-16 17:54:45 +02:00
Torsten Ruger 40581494de class Methods down to vool #24 2019-02-14 19:24:12 +02:00
Torsten Ruger 86e3103543 More or less a stash 2019-02-12 22:41:42 +02:00
Torsten Ruger 37571a0ff9 Add ruby class methods
Ruby parser and ruby level for #24
2019-02-12 22:36:37 +02:00
Torsten Ruger 403540b3ca slightly better messages for unsupported ruby
Very slightly unfortunately, just just enought to find the error.
Also testing what is unsupported, so it's documented.
2019-02-10 21:02:16 +02:00
Torsten Ruger d24b6ee153 start writing parfait witout the module
Parfait classes must be unscoped. Now we start parsing Parfait, it must be without the module.
Luckily module_eval makes this a breeze.
Also remove string interpolation that is not yet processed
2019-02-10 21:00:25 +02:00
Torsten Ruger a89301d623 finally creating less objects in the test
basic still #23 , now applied
Basic size of 20, interpreter gets 50 and the full set is 1024

Tests run more than twice as fast!!
2019-02-09 12:44:35 +02:00
Torsten Ruger 37eeb81f45 fix all tests for previous commit 2019-02-08 23:03:23 +02:00
Torsten Ruger 74b790250a use class variables instead of globals
and set page size from new argument
This closes #23 , though ripples will follow
2019-02-08 23:03:08 +02:00
Torsten Ruger 8d3a1954fa close #21
Mostly replaced Fixnum with integer
also in the rx-file dependency
all travis and testing with 2.4+
2019-02-07 18:24:35 +02:00
Torsten Ruger 51eff62931 Very basic cli to compile ruby files
Off course this is basically a cross compiler and the files
have to be transferred to an arm machine (and fixed as per note)
close #22
2019-02-07 11:07:57 +02:00
Torsten Ruger 4d30727811 test and last fixes for previous commits (allocalte ints)
mostly just fixing the additional instructions
close #20
2018-11-24 22:40:22 +02:00
Torsten Ruger e6615d0a6a remove the old add_new_int and calls
last orrurences in syscalls replaced, 2 variants
- exit does not actually need the int
- all else, preallocate the int beforehand and in syscall assume the reg name (integer_tmp)

test missing
2018-11-22 09:16:56 +02:00
Torsten Ruger a8d1f070f1 replace add_new_int in most builtins
in integer and word mainly, replaced with allocate_int
(tests pending as syscalls are undone)
2018-11-21 20:29:22 +02:00
Torsten Ruger bbb7dbef75 First part of int allocation
implemented allocate_int
instead of add_new_int
2018-11-21 11:12:39 +02:00
Torsten Ruger 5015a11108 function docs improvements 2018-11-14 12:41:13 +02:00
Torsten Ruger fb6a1a0e01 fix the statement moming 2018-11-02 17:27:46 -07:00
Torsten Ruger 4ff84133d2 add append to MomCompiler
also lazy init boot_function, so that compilers can be added up
before going to translate, where the boot_compilers are used
2018-11-02 15:54:30 -07:00
Torsten Ruger 1377bda641 combining sources at vool level
using ScopeStatements
(those unfortunately don't go to_mom)
2018-11-02 12:36:23 -07:00
Torsten Ruger 52f6f1eaa8 cleaner interfaces for rubyXcompiler
store the vool
seperate api for ruby -> X and stored vool -> X
2018-11-02 12:19:13 -07:00
Torsten Ruger 87fc91cd5c start to integrate sources 2018-11-02 11:57:54 -07:00
Torsten Ruger 8a81d41d5e Move booting to RubyXCompiler init
Also pass the source into the compile method.
This way compiler can be reused for subsequent compile.
Does remove some double boots, but no major time save
2018-09-02 13:57:19 +03:00
Torsten Ruger d73e1526cd Some docs and to_s testing
somewhat code_climate inspired
2018-09-01 15:54:25 +03:00
Torsten Ruger 2bb6ad5f61 remove unused code
Arrays and Hashes have to resolve to object creation calls
Not to constants. In the future off course
2018-09-01 15:14:07 +03:00
Torsten Ruger f798173a09 change to_risc and builtin code according to last commit
Wherever space was loaded to get to the next_message
we now load the Message factory.
Otherwise much the same, only the attribute is next_object, not next_message
The binary is growing with 1k objects per factory, so i had to fix (hack) arm to handle bigger constants
close #14
2018-09-01 11:28:53 +03:00
Torsten Ruger d964e9ea9d let spce keep the messages in a factory #14
Like Integers and addresses before, messages are now in a factory
Factories keep allocated (uninitialised) objects, had to make init public to call it
2018-09-01 11:24:16 +03:00
Torsten Ruger 0a390cc5a9 shaves an instruction off resolve_method
by loading nil directly,  not space first
2018-09-01 11:20:59 +03:00
Torsten Ruger c3b026a180 expand constant load
slightly hacky, but in good tradition
previous implementation only worked until 16 significant bits, which is getting to little
this one just keeps adding more instructions to arrive at the constant by force
There are surely cleverer ways of doing this, ie by using the barrel shifter
A start on #15, admittedly a hack
2018-08-31 23:28:31 +03:00
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 253d2fead8 change all to_risc functions to add directly
still #11
test not working yet
2018-08-19 13:18:25 +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 b294208025 continue with #11
slots are the most tricky, especially testing
2018-08-19 13:06:00 +03:00
Torsten Ruger 047a36178f start with #11
by adding striaght to compiler
2018-08-19 12:56:44 +03:00
Torsten Ruger 176b12d896 last two to_risc converted to builder
no change of tests, good sign
2018-08-16 20:28:42 +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 25d7b8bd83 chaning calling convention not to add frame/arg types
these types are only needed to debug and can be gotten from the method (also in the mesage)
just saving the 6 instructions for every call
This was made possible through previous commits on fake_memory access
2018-08-12 14:47:05 +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 b0aefe31fe make all instances attr read writers
unfortunately the writers have to have self.var =
otherwise it is just a local var
Also need to make the type explicit for all
Protocol included memory_length on the class for now
2018-08-11 19:15:34 +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 393ac873c9 change return sequence to return messages to space
as it was before blocks
(thought blocks would make reuse of messages impossible, but was wrong, this only appilies to lambdas)
(too) many tests affected
2018-08-06 14:07:17 +03:00
Torsten Ruger fd25f997ce reqrote return sequence with builder
added test _before_ , same code, just much easier to read
in preparation for returning messages
2018-08-06 13:04:47 +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 308996bf8e fix all tests accordingly to new return 2018-08-02 17:37:27 +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 4d4b691a4b adds a return jump
that will be used to jump to the return sequence
2018-08-02 17:34:44 +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 4fe0edd1e3 first risc level block test working
assign was not executing yield
baecause it was just testing for send, instead of callable
2018-07-30 20:11:52 +03:00
Torsten Ruger 1d2ec8e8ac abstract CallStatement base class, just like in ruby
to_mom differs much more than the to_vool in ruby,
but data and base functionality still warrent unification
also we can check for CallStatement now
2018-07-30 14:45:37 +03:00
Torsten Ruger 198a43cc8d rename callable to CallStatement
Callable is the Method, whereas here we call the method
2018-07-30 14:44:14 +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 a3059108eb compile the blocks too
method_compilers have block_compilers just like
methods have blocks
But assemblers are a flat list
2018-07-30 10:27:32 +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 4839e0d245 minor naming and spaces 2018-07-27 10:46:22 +03:00
Torsten Ruger 700744e6d5 block assignment ruby to vool 2018-07-25 11:06:42 +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 b6c85cd4a4 callable as base for yield and send
more yield tests
2018-07-21 14:34:39 +03:00
Torsten Ruger 6022aa4dab introduce ruby variable and remove ct_type
cleaner oo
2018-07-20 20:53:35 +03:00
Torsten Ruger 235853ab2d first run at ruby block to_vool
leaving the parser structure in the ruby layer,
but adopting the constant approach in vool
2018-07-20 20:07:15 +03:00
Torsten Ruger 0238874c20 fx ruby send args 2018-07-20 20:06:14 +03:00
Torsten Ruger d03592dfb1 fix ruby return 2018-07-20 20:05:32 +03:00
Torsten Ruger 172327f045 fix assignments
which was letting ruby instances through
also rename the doubious copy
2018-07-20 18:13:58 +03:00
Torsten Ruger 6a58a71c0a fix while.to_vool
sanitize normalizer on the way
- return ruby, let caller to_vool
- return single statement, not single? statements
2018-07-20 17:51:17 +03:00
Torsten Ruger 9b8bd57db4 fix if to_vool
and add (simple) hoisting tests
2018-07-20 17:30:08 +03:00
Torsten Ruger 98788b52d3 fix ruby variables 2018-07-20 14:22:26 +03:00
Torsten Ruger f4402ba30f fix local assignment
was missing a method that got lost in copy/paste
also renaming to get guard to pick up tests
2018-07-20 14:16:29 +03:00
Torsten Ruger d14eca3e70 fix assignments to_vool 2018-07-20 13:43:37 +03:00
Torsten Ruger e536a7ac88 fixing send to_vool
was hoisting unneccessarily, because not respecting basics
2018-07-20 13:15:16 +03:00
Torsten Ruger 7b02feae7a fix ruby send statement
remove ruby expression
2018-07-20 10:05:11 +03:00
Torsten Ruger 8cd9818f64 fix ruby return statement
assignment and normalizer on the way
2018-07-20 09:07:09 +03:00
Torsten Ruger a5168ef818 fix ruby class statement 2018-07-19 21:44:48 +03:00
Torsten Ruger 238f09b5ad fix method to_vool 2018-07-19 21:36:28 +03:00
Torsten Ruger 7b4a0126f7 add a helper to get the vool equivalent of a ruby class 2018-07-19 20:59:15 +03:00
Torsten Ruger 77be0d3f73 fixing the ruby creation tests 2018-07-19 16:30:36 +03:00
Torsten Ruger f728725b1a change the ruby block to be like the ruby block
ie modelled like the ast outputs it
2018-07-19 16:22:44 +03:00
Torsten Ruger 61225c2f20 ifx most of the conversion
well . . it's still converting to ruby, minor detail
2018-07-19 14:59:10 +03:00
Torsten Ruger ae3d64eb53 moved all the normalize stuff over to the ruby layer
Which is how it should have been from the start
2018-07-19 14:47:29 +03:00
Torsten Ruger 38350dd198 start a new ruby layer to do the to_vool conversion
the "normalization" is getting more and more complicated and is not tested
And it seems i really don't like working with the untyped ast
2018-07-19 14:46:51 +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 69385c863f some more addresses 2018-07-15 15:13:25 +03:00
Torsten Ruger eaeea29e38 helper erro handling 2018-07-15 12:32:02 +03:00
Torsten Ruger 648ec772ec direct index access helper for type 2018-07-15 12:30:50 +03:00
Torsten Ruger ab8b574e9c also recode the slot_definition resolution
much like in the slot_load. In fact suspiciously so.
wip, as also changing to storing type (not sym) in reg
2018-07-14 22:39:00 +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 581f457119 type helper for class name 2018-07-14 11:03:16 +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 06e78a7326 fix locals scope in method and blocks
methods used to gobble up any locals of included scope. fixed
Blocks now create frame_type correctly and don't include and locals that are in fact method scope
2018-07-09 17:55:45 +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 7c4faf7b2a fix broken test
guard was green before i pushed, i swear
No really
2018-07-07 17:34:48 +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 3f80953385 passing compiler to to_mom, not method
To be able to delegate scope (block/method) things later
2018-07-05 14:02:38 +03:00
Torsten Ruger 16d91f24ce start to test block_statement 2018-07-04 23:21:11 +03:00
Torsten Ruger 2485f7e9eb misc fixes and (finally, sigh) green again
deeeep dive, almost 40 commits
2018-07-04 09:18:55 +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 8b9fd29ce9 Only add Builtin methods that are not in the current compilation
Current bug looks like the original main is used in parts
(not the compiled one, but the builtin on)
2018-07-04 08:28:05 +03:00
Torsten Ruger 2ad24ab0bb add to_s for statements 2018-07-03 22:18:19 +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 63dfee0978 move some tests around (and fix them) 2018-07-02 23:20:54 +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 9bd8eab999 remove class attribute that was left dangling
not used, which prompted rename. just forgot to delete it
2018-07-02 15:50:54 +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 bb49f1be78 rename ClassCompiler to MomComplier
ended up not even using the class, it just came from there
It actually compiles methods, and it turns out is the point where builtin comes into the picture as it's boot process also returns method compilers
2018-07-01 21:26:45 +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