if cache.has_key(mtype) then return cache[mtype]
var res = new Array[AAttrPropdef]
- for cd in mtype.collect_mclassdefs(self.mainmodule)
- do
+ var cds = mtype.collect_mclassdefs(self.mainmodule).to_a
+ self.mainmodule.linearize_mclassdefs(cds)
+ for cd in cds do
var n = self.modelbuilder.mclassdef2nclassdef[cd]
for npropdef in n.n_propdefs do
if npropdef isa AAttrPropdef then
# Check that non nullable attributes of `recv' are correctly initialized.
# This function is used as the last instruction of a new
- # FIXME: this will work better once there is nullable types
fun check_init_instance(recv: Instance)
do
if not recv isa MutableInstance then return
return v.int_instance(recv <=> args[1].val.as(Char))
end
else if cname == "Float" then
+ var recv = args[0].to_f
if pname == "unary -" then
- return v.float_instance(-args[0].to_f)
+ return v.float_instance(-recv)
else if pname == "+" then
- return v.float_instance(args[0].to_f + args[1].to_f)
+ return v.float_instance(recv + args[1].to_f)
else if pname == "-" then
- return v.float_instance(args[0].to_f - args[1].to_f)
+ return v.float_instance(recv - args[1].to_f)
else if pname == "*" then
- return v.float_instance(args[0].to_f * args[1].to_f)
+ return v.float_instance(recv * args[1].to_f)
else if pname == "/" then
- return v.float_instance(args[0].to_f / args[1].to_f)
+ return v.float_instance(recv / args[1].to_f)
+ else if pname == "<" then
+ return v.bool_instance(recv < args[1].to_f)
+ else if pname == ">" then
+ return v.bool_instance(recv > args[1].to_f)
+ else if pname == "<=" then
+ return v.bool_instance(recv <= args[1].to_f)
+ else if pname == ">=" then
+ return v.bool_instance(recv >= args[1].to_f)
else if pname == "to_i" then
- return v.int_instance(args[0].to_f.to_i)
+ return v.int_instance(recv.to_i)
end
else if cname == "NativeString" then
var recvval = args.first.val.as(Buffer)
else if pname == "system" then
var res = sys.system(recvval.to_s)
return v.int_instance(res)
+ else if pname == "atof" then
+ return v.float_instance(recvval.to_f)
end
else if cname == "Int" then
if pname == "rand" then
return v.float_instance(args[0].to_f.cos)
else if pname == "sin" then
return v.float_instance(args[0].to_f.sin)
+ else if pname == "tan" then
+ return v.float_instance(args[0].to_f.tan)
+ else if pname == "acos" then
+ return v.float_instance(args[0].to_f.acos)
+ else if pname == "asin" then
+ return v.float_instance(args[0].to_f.asin)
+ else if pname == "atan" then
+ return v.float_instance(args[0].to_f.atan)
+ else if pname == "sqrt" then
+ return v.float_instance(args[0].to_f.sqrt)
+ else if pname == "exp" then
+ return v.float_instance(args[0].to_f.exp)
+ else if pname == "log" then
+ return v.float_instance(args[0].to_f.log)
+ else if pname == "pow" then
+ return v.float_instance(args[0].to_f.pow(args[1].to_f))
+ else if pname == "rand" then
+ return v.float_instance(args[0].to_f.rand)
end
else if pname == "native_argc" then
return v.int_instance(v.arguments.length)
return v.native_string_instance(txt)
else if pname == "get_time" then
return v.int_instance(get_time)
+ else if pname == "srand_from" then
+ srand_from(args[1].to_i)
+ return null
else if pname == "atan2" then
return v.float_instance(atan2(args[1].to_f, args[2].to_f))
else if pname == "pi" then
# stantard call-next-method
var mpropdef = v.frame.mpropdef
- # FIXME: we do not want an ugly static call!
mpropdef = mpropdef.lookup_next_definition(v.mainmodule, recv.mtype)
assert mpropdef isa MMethodDef
var res = v.call(mpropdef, args)