s = "BOX_NativeString((char*)malloc((UNTAG_Int({p[1]}) * sizeof(char))))"
else
- stderr.write("{locate}: Fatal error: unknown intern method {method.full_name}.\n")
+ stderr.write("{location}: Fatal error: unknown intern method {method.full_name}.\n")
exit(1)
end
if method.signature.return_type != null and s == null then
return location.as(not null) < other.location.as(not null)
end
+
+ redef fun to_s: String do
+ if location == null then
+ return text
+ else
+ return "{location}: {text}"
+ end
+ end
end
# Global context for tools
_message_sorter.sort(_messages)
for m in _messages do
- stderr.write("{m.text}\n")
+ stderr.write("{m}\n")
end
_messages.clear
# Thus, call "v.visit(e)" for each node e starting from the last child
fun visit_all_reverse(v: Visitor) is abstract
- # Give a human readable location of the node.
- fun locate: String
- do
- if location == null then
- return "????"
- end
- return location.to_s
- end
-
# Debug method: output a message prefixed with the location.
fun printl(str: String)
do
- print("{locate}: {str}\n")
+ if location == null then
+ print("???: {str}\n")
+ else
+ print("{location}: {str}\n")
+ end
end
end
# Thus, call "v.visit(e)" for each node e starting from the last child
fun visit_all_reverse(v: Visitor) is abstract
- # Give a human readable location of the node.
- fun locate: String
- do
- if location == null then
- return "????"
- end
- return location.to_s
- end
-
# Debug method: output a message prefixed with the location.
fun printl(str: String)
do
- print("{locate}: {str}\n")
+ if location == null then
+ print("???: {str}\n")
+ else
+ print("{location}: {str}\n")
+ end
end
end
_visitor.error(n, "Error: variable '{v}' is possibly unset.")
var x = self
while true do
- print " {x.node.locate}: {x._set_variables.join(", ")} ; {x._dico.join(", ")}"
+ var loc = x.node.location
+ print " {if loc != null then loc.to_s else "????"}: {x._set_variables.join(", ")} ; {x._dico.join(", ")}"
var x0 = x
if x0 isa SubVariableContext then
x = x0.prev
redef fun to_s
do
var s = new Buffer
- s.append(node.locate)
+ s.append(node.location.to_s)
for v in _all_variables do
var t = stype(v)
if t == null then continue
end
if no_import != null then
if not module_names_to_import.is_empty then
- tc.error(null, "{no_import.locate}: Error: Top modules cannot import other modules.")
+ tc.error(no_import.location, "Error: Top modules cannot import other modules.")
end
else if module_names_to_import.is_empty then
var stdname = once "standard".to_symbol
if node_tree.n_base == null then
var err = node_tree.n_eof
assert err isa PError
- context.fatal_error(err.location, "{err.locate}: {err.message}")
+ context.fatal_error(err.location, err.message)
end
var node_module = node_tree.n_base
assert node_module isa AModule
# Display an error for a given syntax node
fun error(n: nullable PNode, s: String)
do
- _tc.error(n.location, "{locate(n)}: {s}")
+ _tc.error(if n == null then null else n.location, s)
end
# Add an error, show errors and quit
fun fatal_error(n: nullable PNode, s: String)
do
- _tc.fatal_error(n.location, "{locate(n)}: {s}")
+ _tc.fatal_error(if n == null then null else n.location, s)
end
# Display a warning for a given syntax node
fun warning(n: nullable PNode, s: String)
do
- _tc.warning(n.location, "{locate(n)}: {s}")
- end
-
- #
- fun locate(n: nullable PNode): String
- do
- if n != null then return n.locate
- return _module.location.file
+ _tc.warning(if n == null then null else n.location, s)
end
# Check conformity and display error
do
if not n.is_typed then
if tc.error_count == 0 then
- print("{n.locate} not typed but not error")
+ var loc = n.location
+ if loc == null then
+ print("Unknown node not typed but not error")
+ else
+ print("{loc} not typed but not error")
+ end
abort
end
# An error occured in a sub node,
redef fun stype
do
if not is_typed then
- print "{locate}: not is_typed"
+ print "{location}: not is_typed"
abort
end
if is_statement then
- print "{locate}: is_statement"
+ print "{location}: is_statement"
abort
end
return _stype.as(not null)