nitc :: APropdef :: compile_to_c
fun compile_to_c(v: AbstractCompilerVisitor, mpropdef: MMethodDef, arguments: Array[RuntimeVariable])
do
v.add("PRINT_ERROR(\"NOT YET IMPLEMENTED {class_name} {mpropdef} at {location.to_s}\\n\");")
debug("Not yet implemented")
end
src/compiler/abstract_compiler.nit:2614,2--2618,4
redef fun compile_to_c(v, mpropdef, arguments)
do
if mpropdef == mreadpropdef then
assert arguments.length == 1
var recv = arguments.first
var res
if is_lazy then
var set
var ret = self.mtype
var useiset = not ret.is_c_primitive and not ret isa MNullableType
var guard = self.mlazypropdef.mproperty
if useiset then
set = v.isset_attribute(self.mpropdef.mproperty, recv)
else
set = v.read_attribute(guard, recv)
end
v.add("if(likely({set})) \{")
res = v.read_attribute(self.mpropdef.mproperty, recv)
v.add("\} else \{")
var value = evaluate_expr(v, recv)
v.assign(res, value)
if not useiset then
var true_v = v.bool_instance(true)
v.write_attribute(guard, arguments.first, true_v)
end
v.add("\}")
else
res = v.read_attribute(self.mpropdef.mproperty, arguments.first)
end
v.assign(v.frame.returnvar.as(not null), res)
else if mpropdef == mwritepropdef then
assert arguments.length == 2
var recv = arguments.first
var arg = arguments[1]
if is_optional and v.maybe_null(arg) then
var value = v.new_var(self.mpropdef.static_mtype.as(not null))
v.add("if ({arg} == NULL) \{")
v.assign(value, evaluate_expr(v, recv))
v.add("\} else \{")
v.assign(value, arg)
v.add("\}")
arg = value
end
v.write_attribute(self.mpropdef.mproperty, arguments.first, arg)
if is_lazy then
var ret = self.mtype
var useiset = not ret.is_c_primitive and not ret isa MNullableType
if not useiset then
v.write_attribute(self.mlazypropdef.mproperty, arguments.first, v.bool_instance(true))
end
end
else
abort
end
end
src/compiler/abstract_compiler.nit:3564,2--3620,4
redef fun compile_to_c(v, mpropdef, arguments)
do
# Call the implicit super-init
var auto_super_inits = self.auto_super_inits
if auto_super_inits != null then
var args = [arguments.first]
for auto_super_init in auto_super_inits do
assert auto_super_init.mproperty != mpropdef.mproperty
args.clear
for i in [0..auto_super_init.msignature.arity+1[ do
args.add(arguments[i])
end
assert auto_super_init.mproperty != mpropdef.mproperty
v.compile_callsite(auto_super_init, args)
end
end
if auto_super_call then
v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments)
end
# Try special compilation
if mpropdef.is_intern then
if compile_intern_to_c(v, mpropdef, arguments) then return
end
if mpropdef.is_extern then
if mpropdef.mproperty.is_init then
if compile_externinit_to_c(v, mpropdef, arguments) then return
else
if compile_externmeth_to_c(v, mpropdef, arguments) then return
end
end
# Compile block if any
var n_block = n_block
if n_block != null then
for i in [0..mpropdef.msignature.arity[ do
var variable = self.n_signature.n_params[i].variable.as(not null)
v.assign(v.variable(variable), arguments[i+1])
end
v.stmt(n_block)
return
end
# We have a problem
v.add_raw_throw
var cn = v.class_name_string(arguments.first)
v.add("PRINT_ERROR(\"Runtime error: uncompiled method `%s` called on `%s`. NOT YET IMPLEMENTED\", \"{mpropdef.mproperty.name.escape_to_c}\", {cn});")
v.add_raw_abort
end
src/compiler/abstract_compiler.nit:2624,2--2672,4