nitc :: CallArg :: from_static_type
static_type
Opposite of to_instance
.
# Set the content of this cell according to `static_type`
#
# Opposite of `to_instance`.
fun from_static_type(value: Instance, static_type: MType)
do
if static_type.name == "Int" then
assert value isa PrimitiveInstance[Int]
self.int = value.val
else if static_type.name == "Bool" then
assert value isa PrimitiveInstance[Bool]
self.bool = value.val
else if static_type.name == "Char" then
assert value isa PrimitiveInstance[Char]
self.char = value.val
else if static_type.name == "Byte" then
assert value isa PrimitiveInstance[Byte]
self.byte = value.val
else if static_type.name == "Int8" then
assert value isa PrimitiveInstance[Int8]
self.int8 = value.val
else if static_type.name == "Int16" then
assert value isa PrimitiveInstance[Int16]
self.int16 = value.val
else if static_type.name == "UInt16" then
assert value isa PrimitiveInstance[UInt16]
self.uint16 = value.val
else if static_type.name == "Int32" then
assert value isa PrimitiveInstance[Int32]
self.int32 = value.val
else if static_type.name == "UInt32" then
assert value isa PrimitiveInstance[UInt32]
self.uint32 = value.val
else if static_type.name == "Float" then
assert value isa PrimitiveInstance[Float]
self.float = value.val
else if static_type.name == "CString" then
assert value isa PrimitiveInstance[CString]
self.pointer = value.val
else if static_type isa MClassType and static_type.mclass.kind == extern_kind then
assert value isa PrimitiveInstance[Pointer] else print value.class_name
self.pointer = value.val
else
self.instance = value
end
end
src/interpreter/dynamic_loading_ffi/dynamic_loading_ffi.nit:136,2--180,4