nitc :: CallArg :: to_instance
Instance
of the static_type
Opposite of from_static_type
.
# Get the content of this cell as an `Instance` of the `static_type`
#
# Opposite of `from_static_type`.
fun to_instance(static_type: MType, v: NaiveInterpreter): Instance
do
var name = static_type.name
if name == "Int" then
return v.int_instance(self.int)
else if name == "Bool" then
return if self.bool then
v.true_instance
else v.false_instance
else if name == "Char" then
return v.char_instance(self.char)
else if name == "Byte" then
return v.byte_instance(self.byte)
else if name == "Int8" then
return v.int8_instance(self.int8)
else if name == "Int16" then
return v.int16_instance(self.int16)
else if name == "UInt16" then
return v.uint16_instance(self.uint16)
else if name == "Int32" then
return v.int32_instance(self.int32)
else if name == "UInt32" then
return v.uint32_instance(self.uint32)
else if name == "Float" then
return v.float_instance(self.float)
else if name == "CString" then
var instance = new PrimitiveInstance[CString](static_type, self.c_string)
v.init_instance_primitive instance
return instance
else if static_type isa MClassType and static_type.mclass.kind == extern_kind then
# We tag it with the most precise known type
var instance = new PrimitiveInstance[Pointer](static_type, self.pointer)
v.init_instance_primitive instance
return instance
else
return self.instance
end
end
src/interpreter/dynamic_loading_ffi/dynamic_loading_ffi.nit:182,2--222,4