fun send_commons(mproperty: MMethod, args: Array[Instance], mtype: MType): nullable Instance
do
if mtype isa MNullType then
- if mproperty.name == "==" then
+ if mproperty.name == "==" or mproperty.name == "is_same_instance" then
return self.bool_instance(args[0] == args[1])
else if mproperty.name == "!=" then
return self.bool_instance(args[0] != args[1])
return v.int_instance(args[0].to_i.bin_xor(args[1].to_i))
else if pname == "bin_not" then
return v.int_instance(args[0].to_i.bin_not)
+ else if pname == "int_to_s_len" then
+ return v.int_instance(recvval.to_s.length)
else if pname == "native_int_to_s" then
- return v.native_string_instance(recvval.to_s)
+ var s = recvval.to_s
+ var srecv = args[1].val.as(Buffer)
+ srecv.clear
+ srecv.append(s)
+ srecv.add('\0')
+ return null
else if pname == "strerror_ext" then
return v.native_string_instance(recvval.strerror)
end
if fromval < 0 then
debug("Illegal access on {recvval} for element {fromval}/{recvval.length}")
end
- if fromval + lenval >= recvval.length then
+ if fromval + lenval > recvval.length then
debug("Illegal access on {recvval} for element {fromval}+{lenval}/{recvval.length}")
end
if toval < 0 then
debug("Illegal access on {destval} for element {toval}/{destval.length}")
end
- if toval + lenval >= destval.length then
+ if toval + lenval > destval.length then
debug("Illegal access on {destval} for element {toval}+{lenval}/{destval.length}")
end
recvval.as(FlatBuffer).copy(fromval, lenval, destval, toval)
# Return a possible value
# NOTE: Do not call this method directly, but use `v.expr`
# This method is here to be implemented by subclasses.
- private fun expr(v: NaiveInterpreter): nullable Instance
+ protected fun expr(v: NaiveInterpreter): nullable Instance
do
fatal(v, "NOT YET IMPLEMENTED expr {class_name}")
abort
# Evaluate the node as a statement.
# NOTE: Do not call this method directly, but use `v.stmt`
# This method is here to be implemented by subclasses (no need to return something).
- private fun stmt(v: NaiveInterpreter)
+ protected fun stmt(v: NaiveInterpreter)
do
expr(v)
end