2018-03-11 17:02:42 +05:30
|
|
|
module Risc
|
2016-12-09 13:56:13 +02:00
|
|
|
|
2019-08-06 18:33:27 +03:00
|
|
|
# MethodCompiler is used to generate risc instructions for methods
|
|
|
|
# and to instantiate the methods correctly.
|
2015-10-28 21:36:41 +02:00
|
|
|
|
2018-07-10 22:02:11 +03:00
|
|
|
class MethodCompiler < CallableCompiler
|
2015-05-08 15:10:30 +03:00
|
|
|
|
2019-08-10 12:42:47 +03:00
|
|
|
# Methods starts with a Label, both in risc and mom.
|
|
|
|
# Pass in the callable(method) and the mom label that the method starts with
|
|
|
|
def initialize( method , mom_label)
|
|
|
|
super(method , mom_label)
|
2015-09-19 18:56:18 +03:00
|
|
|
end
|
2018-06-29 13:03:19 +03:00
|
|
|
|
2018-08-01 16:27:34 +03:00
|
|
|
#include block_compilers constants
|
|
|
|
def constants
|
|
|
|
block_compilers.inject(@constants.dup){|all, compiler| all += compiler.constants}
|
|
|
|
end
|
|
|
|
|
2018-07-10 22:02:11 +03:00
|
|
|
def source_name
|
2018-07-30 10:26:11 +03:00
|
|
|
"#{@callable.self_type.name}.#{@callable.name}"
|
2018-07-10 22:02:11 +03:00
|
|
|
end
|
2018-07-30 10:26:11 +03:00
|
|
|
|
2018-07-09 19:32:17 +03:00
|
|
|
# sometimes the method is used as source (tb reviewed)
|
|
|
|
def source
|
2018-07-30 10:26:11 +03:00
|
|
|
@callable
|
2018-07-09 19:32:17 +03:00
|
|
|
end
|
2018-07-30 10:26:11 +03:00
|
|
|
|
2018-07-09 16:48:23 +03:00
|
|
|
def add_block_compiler(compiler)
|
|
|
|
@block_compilers << compiler
|
|
|
|
end
|
|
|
|
|
2015-05-08 15:10:30 +03:00
|
|
|
end
|
|
|
|
end
|