marekjm / viuavm

Parallel virtual machine designed to reliably run massively concurrent programs
https://viuavm.org/
GNU General Public License v3.0
71 stars 11 forks source link

Generic operator instructions #126

Closed marekjm closed 8 years ago

marekjm commented 8 years ago

Generic operator instructions would be mul, add, eq etc. They would be just "funny looking function calls", i.e. they would silently create a frame and call the function associated by given operation for the recipient of the message.

Example:

new 2 Foo
new 3 Bar
mul 1 2 3

could be translated to:

frame ^[(param 0 (ptr 4 (new 2 Foo))) (param 1 (ptr 5 (new 3 Bar)))]
msg 1 __multiply

Clearly, the first form is much shorter.

This would be most useful for custom types, as built-ins have their dedicated operator instructions.

marekjm commented 8 years ago

This is too high-level to be implemented in machine's core. Operator overloading should be resolved by compilers, on the assembly level they should look like ordinary function calls.