Commit Graph

197 Commits

Author SHA1 Message Date
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
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
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
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
dee1e24c28 Fix ruby receiver to vool
for chained calls to be normalized correctly
2019-08-16 16:05:45 +03:00
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
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
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
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
155c042009 Fix forgotten block compiler
Especially on the way down to risc
2019-08-13 19:32:17 +03:00
3282e0ae06 transformed object builtins 2019-08-11 20:36:10 +03:00
0b59c95218 more test fixes and more to do 2019-08-10 21:59:31 +03:00
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
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
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 Ruger
461a6933c6 better tests for class sending
still #24
2019-02-23 18:17:26 +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
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
37571a0ff9 Add ruby class methods
Ruby parser and ruby level for #24
2019-02-12 22:36:37 +02:00
Torsten Ruger
fb6a1a0e01 fix the statement moming 2018-11-02 17:27:46 -07: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
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
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
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
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
1cb07a4164 block arg access was off by one 2018-07-27 12:16:06 +03:00
Torsten Ruger
4839e0d245 minor naming and spaces 2018-07-27 10:46:22 +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
b6c85cd4a4 callable as base for yield and send
more yield tests
2018-07-21 14:34:39 +03:00
Torsten Ruger
0238874c20 fx ruby send args 2018-07-20 20:06:14 +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
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
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
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
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
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
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