meth compile_call(v: CompilerVisitor, cargs: Array[String]): String
do
var i = self
- assert i isa MMSrcMethod
- if i.node isa AInternMethPropdef or
- (i.local_class.name == (once "Array".to_symbol) and name == (once "[]".to_symbol))
- then
- var e = i.do_compile_inside(v, cargs)
- return e
+ if i isa MMSrcMethod then
+ if i isa MMMethSrcMethod and i.node isa AInternMethPropdef or
+ (i.local_class.name == (once "Array".to_symbol) and name == (once "[]".to_symbol))
+ then
+ var e = i.do_compile_inside(v, cargs)
+ return e
+ end
end
var ee = once "==".to_symbol
var ne = once "!=".to_symbol
var ctx_old = v.ctx
v.ctx = new CContext
- v.add_decl("struct trace_t trace = \{NULL, NULL, {node.line_number}, LOCATE_{cname}};")
+ var ln = 0
+ var s = self
+ if s.node != null then ln = s.node.line_number
+ v.add_decl("struct trace_t trace = \{NULL, NULL, {ln}, LOCATE_{cname}};")
v.add_instr("trace.prev = tracehead; tracehead = &trace;")
v.add_instr("trace.file = LOCATE_{module.name};")
var s = do_compile_inside(v, args)
redef class MMLocalProperty
# The attached node (if any)
meth node: PNode do return null
+
+ # Is the concrete method defined as init
+ meth is_init: Bool do return false
end
# Concrete NIT source attribute
class MMSrcAttribute
-special MMLocalProperty
special MMAttribute
redef readable attr _node: AAttrPropdef
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
# Concrete NIT source method
class MMSrcMethod
-special MMLocalProperty
special MMMethod
end
class MMAttrImplementationMethod
special MMSrcMethod
redef readable attr _node: AAttrPropdef
+ init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
+ do
+ super(name, cla)
+ _node = n
+ end
end
# Concrete NIT source method for an automatic read accesor
class MMReadImplementationMethod
special MMAttrImplementationMethod
-
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
- super(name, cla)
- _node = n
+ super(name, cla, n)
end
end
# Concrete NIT source method for an automatic write accesor
class MMWriteImplementationMethod
special MMAttrImplementationMethod
-
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
- super(name, cla)
- _node = n
+ super(name, cla, n)
end
end
# Concrete NIT source method for an explicit method
class MMMethSrcMethod
special MMSrcMethod
+ redef meth is_init do return _node isa AConcreteInitPropdef
redef readable attr _node: AMethPropdef
init(name: Symbol, cla: MMLocalClass, n: AMethPropdef)
do
# Display an error for a given syntax node
meth error(n: PNode, s: String)
do
- _tc.error("{n.locate}: {s}")
+ _tc.error("{locate(n)}: {s}")
end
# Display a warning for a given syntax node
meth warning(n: PNode, s: String)
do
- _tc.warning("{n.locate}: {s}")
+ _tc.warning("{locate(n)}: {s}")
+ end
+
+ #
+ meth locate(n: PNode): String
+ do
+ if n != null then return n.locate
+ return _module.filename
end
# Check conformity and display error