# limitations under the License.
# Tools to manipulate intermediace nit code representation
+module icode_tools
import icode_builder
# A simple visitor to visit icode structures
end
redef class ICodeBuilder
- # IRoutine currently inlining
- # Used to avoid recursive inlining
- var _current_inlining: Array[IRoutine] = new Array[IRoutine]
-
- # Return false if routine can be saflely inlined
- fun is_currently_inlining_routine(routine: IRoutine): Bool
- do
- return routine == iroutine or _current_inlining.has(routine)
- end
-
# Inline an iroutine in the current icode sequence
- # Require not is_currently_inlining
+ # Require that routine != self.iroutine
fun inline_routine(routine: IRoutine, args: Sequence[IRegister], closdefs: nullable Sequence[nullable IClosureDef]): nullable IRegister
do
- assert not is_currently_inlining_routine(routine)
- _current_inlining.add(routine)
+ assert routine != self.iroutine
var d = new ICodeDupContext(self)
assert args.length == routine.params.length
var closdecls = routine.closure_decls
# Process inlining
routine.body.dup_with(d)
- _current_inlining.pop
return res
end
end
redef class INative
redef fun inner_dup_with(d)
do
- var c2 = new INative(code, d.dup_iregs(exprs))
+ var c2 = new INative(method, d.dup_iregs(exprs))
c2.is_pure = is_pure
return c2
end
end
+redef class IIntValue
+ redef fun inner_dup_with(d)
+ do
+ return new IIntValue(value)
+ end
+end
+
+redef class IBoolValue
+ redef fun inner_dup_with(d)
+ do
+ return new IBoolValue(value)
+ end
+end
+
+redef class IStringValue
+ redef fun inner_dup_with(d)
+ do
+ return new IStringValue(value)
+ end
+end
+
+redef class IFloatValue
+ redef fun inner_dup_with(d)
+ do
+ return new IFloatValue(value)
+ end
+end
+
+redef class ICharValue
+ redef fun inner_dup_with(d)
+ do
+ return new ICharValue(value)
+ end
+end
+
redef class IMove
redef fun inner_dup_with(d)
do