import semantize
private import parser::tables
import mixin
-import primitive_types
private import model::serialize_model
private import frontend::explain_assert_api
return instance
end
+ # Return a new C string instance sharing the same data space as `txt`
+ fun c_string_instance_fast_cstr(txt: CString, from: Int): Instance
+ do
+ var ncstr = txt.fast_cstring(from)
+ var t = mainmodule.c_string_type
+
+ var instance = new PrimitiveInstance[CString](t, ncstr)
+ init_instance_primitive(instance)
+
+ return instance
+ end
+
# Return a new C string initialized of `length`
fun c_string_instance_len(length: Int): PrimitiveInstance[CString]
do
super Frame
# Mapping between a variable and the current value
- private var map: Map[Variable, Instance] = new HashMap[Variable, Instance]
+ var map: Map[Variable, Instance] = new HashMap[Variable, Instance]
end
redef class ANode
return res
end
- private fun call_commons(v: NaiveInterpreter, mpropdef: MMethodDef, arguments: Array[Instance], f: Frame): nullable Instance
+ # Execution of the body of the method
+ #
+ # It handle the common special cases: super, intern, extern
+ fun call_commons(v: NaiveInterpreter, mpropdef: MMethodDef, arguments: Array[Instance], f: Frame): nullable Instance
do
v.frames.unshift(f)
else if pname == "atoi" then
return v.int_instance(recvval.atoi)
else if pname == "fast_cstring" then
- var ns = recvval.fast_cstring(args[1].to_i)
- return v.c_string_instance(ns.to_s)
+ return v.c_string_instance_fast_cstr(args[0].val.as(CString), args[1].to_i)
else if pname == "fetch_4_chars" then
return v.uint32_instance(args[0].val.as(CString).fetch_4_chars(args[1].to_i))
else if pname == "fetch_4_hchars" then
var i = v.expr(ne)
if i == null then return
v.escapevalue = i
+ else
+ v.escapevalue = null
end
v.escapemark = self.escapemark
end