# Concrete NIT source local classs by name
readable var _src_local_classes: Map[Symbol, MMSrcLocalClass]
- init(c: MMContext, source: AModule, dir: MMDirectory, name: Symbol, filename: String)
+ init(c: MMContext, source: AModule, dir: MMDirectory, name: Symbol, loc: Location)
do
- super(name, dir, c, filename)
+ super(name, dir, c, loc)
_node = source
_src_local_classes = new HashMap[Symbol, MMSrcLocalClass]
end
# Concrete NIT source method
class MMSrcMethod
special MMMethod
+ redef fun is_intern do return false
+ redef fun is_abstract do return false
end
# Concrete NIT source method for an automatic accesor
# Concrete NIT source method for an explicit method
class MMMethSrcMethod
special MMSrcMethod
- redef fun is_init do return _node isa AConcreteInitPropdef
+ redef readable var _is_init: Bool
+ redef readable var _is_intern: Bool
+ redef readable var _is_abstract: Bool
redef readable var _node: nullable AMethPropdef
init(name: Symbol, cla: MMLocalClass, n: nullable AMethPropdef)
do
super(name, cla)
_node = n
+ _is_init = node isa AConcreteInitPropdef
+ _is_intern = node isa AInternMethPropdef
+ _is_abstract = node isa ADeferredMethPropdef
end
end
return _module.type_none
end
+ fun get_method(recv: MMType, name: Symbol): MMMethod
+ do
+ if not recv.local_class.has_global_property_by_name(name) then
+ error(current_node, "Fatal Error: {recv} must have a property named {name}.")
+ exit(1)
+ end
+ return recv.local_class.select_method(name)
+ end
+
# The current module
readable var _module: MMSrcModule
# Display an error for a given syntax node
fun error(n: nullable PNode, s: String)
do
- _tc.error("{locate(n)}: {s}")
+ _tc.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)
+ # Add an error, show errors and quit
+ fun fatal_error(n: nullable PNode, s: String)
do
- _tc.warning("{locate(n)}: {s}")
+ _tc.fatal_error(if n == null then null else n.location, s)
end
- #
- fun locate(n: nullable PNode): String
+ # Display a warning for a given syntax node
+ fun warning(n: nullable PNode, s: String)
do
- if n != null then return n.locate
- return _module.filename
+ _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,
if node == null then
error(n, "Type error: no most general type. Got {n.stype} and {stype}.")
else
- error(n, "Type error: no most general type. Got {n.stype} and {stype} at {node.locate}.")
+ var loc = node.location
+ if loc == null then
+ error(n, "Type error: no most general type. Got {n.stype} and {stype} at ????.")
+ else
+ error(n, "Type error: no most general type. Got {n.stype} and {stype} at {loc.relative_to(n.location)}.")
+ end
end
return null
end
fun local_class: MMSrcLocalClass is abstract
end
+redef class PPropdef
+ # Associated 'self' variable
+ fun self_var: ParamVariable is abstract
+end
+
redef class AAttrPropdef
# Associated attribute (MM entity)
fun prop: MMSrcAttribute is abstract
redef class AMethPropdef
# Associated method (MM entity)
fun method: MMMethSrcMethod is abstract
-
- # Associated 'self' variable
- fun self_var: ParamVariable is abstract
end
redef class ATypePropdef
fun attr_type: MMType is abstract
end
-redef class AStringFormExpr
- fun meth_with_native: MMMethod is abstract
-end
-
redef class ASuperstringExpr
- fun meth_with_capacity: MMMethod is abstract
- fun meth_add: MMMethod is abstract
- fun meth_to_s: MMMethod is abstract
fun atype: MMType is abstract
end
-redef class AArrayExpr
- fun meth_with_capacity: MMMethod is abstract
- fun meth_add: MMMethod is abstract
-end
-
-redef class ARangeExpr
- fun meth_init: MMMethod is abstract
-end
-
redef class AVardeclExpr
# Assiociated local variable
fun variable: VarVariable is abstract
redef class AForExpr
# Associated automatic local variable
fun variable: AutoVariable is abstract
- fun meth_iterator: MMMethod is abstract
- fun meth_is_ok: MMMethod is abstract
- fun meth_item: MMMethod is abstract
- fun meth_next: MMMethod is abstract
end
redef class ASelfExpr
# Associated local variable
fun variable: ParamVariable is abstract
- #readable writable var _variable: nullable ParamVariable
end
redef class AVarFormExpr
# Associated local variable
fun variable: Variable is abstract
- #readable writable var _variable: nullable Variable
end
redef class AClosureCallExpr
special AAbsAbsSendExpr
# Associated closure variable
fun variable: ClosureVariable is abstract
- #readable writable var _variable: nullable ClosureVariable
end
redef class PClosureDef
# Associated closure
- #readable writable var _closure: nullable MMClosure
fun closure: MMClosure is abstract
# Automatic variables