end
# Check that `sub` is a subtype of `sup`.
- # If `sub` is not a valid suptype, then display an error on `node` an return null.
- # If `sub` is a safe subtype of `sup` then return `sub`.
- # If `sub` is an unsafe subtype (ie an implicit cast is required), then return `sup`.
+ # If `sub` is not a valid suptype, then display an error on `node` and return `null`.
+ # If `sub` is a safe subtype of `sup`, then return `sub`.
+ # If `sub` is an unsafe subtype (i.e., an implicit cast is required), then return `sup`.
#
# The point of the return type is to determinate the usable type on an expression when `autocast` is true:
# If the suptype is safe, then the return type is the one on the expression typed by `sub`.
if map == null then is_broken = true
return map == null
end
+
+ # Information about the callsite to display on a node
+ fun dump_info(v: ASTDump): String do
+ return "{recv}.{mpropdef}{msignature}"
+ end
end
redef class Variable
#
# This attribute is meaning less on expressions not used as attributes.
var vararg_decl: Int = 0
+
+ redef fun dump_info(v) do
+ var res = super
+ var mtype = self.mtype
+ if mtype != null then
+ res += v.yellow(":{mtype}")
+ end
+ var ict = self.implicit_cast_to
+ if ict != null then
+ res += v.yellow("(.as({ict}))")
+ end
+ return res
+ end
end
redef class ABlockExpr
var newline: nullable CallSite = null
# Regex::extended, used for suffix `b` on `re`
var extended: nullable CallSite = null
- # NativeString::to_bytes_with_copy, used for prefix `b`
+ # CString::to_bytes_with_copy, used for prefix `b`
var to_bytes_with_copy: nullable CallSite = null
redef fun accept_typing(v) do
var mclass = v.get_mclass(self, "String")
if mclass == null then return # Forward error
if is_bytestring then
- to_bytes_with_copy = v.get_method(self, v.mmodule.native_string_type, "to_bytes_with_copy", false)
+ to_bytes_with_copy = v.get_method(self, v.mmodule.c_string_type, "to_bytes_with_copy", false)
mclass = v.get_mclass(self, "Bytes")
else if is_re then
to_re = v.get_method(self, mclass.mclass_type, "to_re", false)
do
v.check_expr_cast(self, self.n_expr, self.n_type)
end
+
+ redef fun dump_info(v) do
+ var res = super
+ var mtype = self.cast_type
+ if mtype != null then
+ res += v.yellow(".as({mtype})")
+ end
+ return res
+ end
+
end
redef class AAsCastExpr
fun raw_arguments: Array[AExpr] do return compute_raw_arguments
private fun compute_raw_arguments: Array[AExpr] is abstract
+
+ redef fun dump_info(v) do
+ var res = super
+ var callsite = self.callsite
+ if callsite != null then
+ res += v.yellow(" call="+callsite.dump_info(v))
+ end
+ return res
+ end
end
redef class ABinopExpr
self.is_typed = true
end
+
+ redef fun dump_info(v) do
+ var res = super
+ var callsite = self.callsite
+ if callsite != null then
+ res += v.yellow(" super-init="+callsite.dump_info(v))
+ end
+ var mpropdef = self.mpropdef
+ if mpropdef != null then
+ res += v.yellow(" call-next-method="+mpropdef.to_s)
+ end
+ return res
+ end
end
####
var args = n_args.to_a
callsite.check_signature(v, node, args)
end
+
+ redef fun dump_info(v) do
+ var res = super
+ var callsite = self.callsite
+ if callsite != null then
+ res += v.yellow(" call="+callsite.dump_info(v))
+ end
+ return res
+ end
end
####
attr_type = v.resolve_for(attr_type, recvtype, self.n_expr isa ASelfExpr)
self.attr_type = attr_type
end
+
+ redef fun dump_info(v) do
+ var res = super
+ var mproperty = self.mproperty
+ var attr_type = self.attr_type
+ if mproperty != null then
+ res += v.yellow(" attr={mproperty}:{attr_type or else "BROKEN"}")
+ end
+ return res
+ end
end
redef class AAttrExpr