nitc :: ANode :: _is_broken
The indication that the node did not pass some semantic verifications.nitc :: ANode :: accept_ast_validation
nitc :: ANode :: accept_auto_super_init
nitc :: ANode :: accept_flow_visitor
nitc :: ANode :: accept_forward_analysis
Apply the forward analysisv
to self
.
nitc :: ANode :: accept_literal
nitc :: ANode :: accept_post_typing
nitc :: ANode :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: ANode :: accept_reaching_defs
Apply a ReachingDefsAnalysis toself
.
nitc :: ANode :: accept_regex_visitor
nitc :: ANode :: accept_scope_visitor
nitc :: ANode :: accept_simple_misc
nitc :: ANode :: accept_string_finder
nitc :: ANode :: after_simple_misc
nitc :: ANode :: bad_expr_message
An additional information message to explain the role of a child expression.nitc :: ANode :: check_callsite
nitc :: ANode :: collect_annotations_by_name
Do a deep search and return an array of node that are annotatednitc :: ANode :: collect_length
Collect the length (inChar
) of the node.
nitc :: ANode :: collect_tokens_by_text
Do a deep search and return an array of tokens that match a given textnitc :: ANode :: common_parent
The most specific common parent betweenself
and other
nitc :: ANode :: create_contracts
nitc :: ANode :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: ANode :: defaultinit
nitc :: ANode :: do_cloneable
nitc :: ANode :: force_block=
Forceself
to be rendered as a block.
nitc :: ANode :: force_inline=
Forceself
to be rendered as a line.
nitc :: ANode :: full_transform_visitor
nitc :: ANode :: hot_location
The location of the important part of the node (identifier or whatever)nitc :: ANode :: is_broken=
The indication that the node did not pass some semantic verifications.nitc :: ANode :: is_noserialize
Is this node annotated to not be made serializable?nitc :: ANode :: is_serialize
Is this node annotated to be made serializable?nitc :: ANode :: is_structural
Isself
a token or a pure-structural production like AQId
?
nitc :: ANode :: must_be_block
Doesself
have to be rendered as a block?
nitc :: ANode :: must_be_inline
Doesself
have be rendered as a line?
nitc :: ANode :: parentize_tokens
Visit the AST and computes advanced AST attributes on Tokens and Prodnitc :: ANode :: replace_child
Replace a child with an other node in the ASTnitc :: ANode :: replace_with
Replace itself with an other node in the ASTnitc :: ANode :: was_inline
Doesself
was written in one line before transformation?
nitc :: ANode :: _is_broken
The indication that the node did not pass some semantic verifications.nitc :: ANode :: accept_ast_validation
nitc :: ANode :: accept_auto_super_init
nitc :: ANode :: accept_flow_visitor
nitc :: ANode :: accept_forward_analysis
Apply the forward analysisv
to self
.
nitc :: ANode :: accept_literal
nitc :: ANode :: accept_post_typing
nitc :: ANode :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: ANode :: accept_reaching_defs
Apply a ReachingDefsAnalysis toself
.
nitc :: ANode :: accept_regex_visitor
nitc :: ANode :: accept_scope_visitor
nitc :: ANode :: accept_simple_misc
nitc :: ANode :: accept_string_finder
nitc :: ANode :: after_simple_misc
nitc :: ANode :: bad_expr_message
An additional information message to explain the role of a child expression.nitc :: ANode :: check_callsite
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: ANode :: collect_annotations_by_name
Do a deep search and return an array of node that are annotatednitc :: ANode :: collect_length
Collect the length (inChar
) of the node.
nitc :: ANode :: collect_tokens_by_text
Do a deep search and return an array of tokens that match a given textnitc :: ANode :: common_parent
The most specific common parent betweenself
and other
nitc :: ANode :: create_contracts
nitc :: ANode :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: ANode :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: ANode :: do_cloneable
nitc :: ANode :: force_block=
Forceself
to be rendered as a block.
nitc :: ANode :: force_inline=
Forceself
to be rendered as a line.
nitc :: ANode :: full_transform_visitor
nitc :: ANode :: hot_location
The location of the important part of the node (identifier or whatever)nitc :: ANode :: is_broken=
The indication that the node did not pass some semantic verifications.nitc :: ANode :: is_noserialize
Is this node annotated to not be made serializable?core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: ANode :: is_serialize
Is this node annotated to be made serializable?nitc :: ANode :: is_structural
Isself
a token or a pure-structural production like AQId
?
nitc :: ANode :: must_be_block
Doesself
have to be rendered as a block?
nitc :: ANode :: must_be_inline
Doesself
have be rendered as a line?
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: ANode :: parentize_tokens
Visit the AST and computes advanced AST attributes on Tokens and Prodnitc :: ANode :: replace_child
Replace a child with an other node in the ASTnitc :: ANode :: replace_with
Replace itself with an other node in the ASTnitc :: ANode :: was_inline
Doesself
was written in one line before transformation?
nitc :: AAsNotNullableExternCall
A single callback declaration on a cast to a non-nullable type= something
nitc :: ABinOpHelper
Used to factorize work on Or, And, Implies and Binop expressions.nitc :: ABraFormExpr
Whatever looks-like a call of the brackets[]
operator.
x[y,z]+=t
x.m(y)=z
. OR just a simple assignment.
x.m(y)+=z
. OR just a simple complex assignment.
nitc :: ACallrefExpr
A reference to a method with a captured receiver. eg.&x.foo
or just &foo
is self is captured.
nitc :: AClasskind
The modifier for the kind of class (abstract, interface, etc.)class
)
nitc :: AIfexprExpr
Aif
expression (ternary conditional). eg. if true then 1 else 0
self
is implicit
nitc :: ALambdaExpr
nitc :: AModuledecl
The declaration of the module with the documentation, name, and annotations+= something
nitc :: AStdClassdef
A standard class definition with a name, superclasses and propertiesnitc :: AVarargExpr
An ellipsis notation used to pass an expression as it, in a vararg parameternitc :: AugmentedStringFormExpr
Any kind of string form with augmentations from prefixes or suffixes
# Root of the AST class-hierarchy
abstract class ANode
# Location is set during AST building. Once built, location can not be null.
# However, manual instantiated nodes may need more care.
var location: Location is writable, noinit
# The location of the important part of the node (identifier or whatever)
fun hot_location: Location do return location
# Display a message for the colored location of the node
fun debug(message: String)
do
sys.stderr.write "{hot_location} {self.class_name}: {message}\n{hot_location.colored_line("0;32")}\n"
end
# Is `self` a token or a pure-structural production like `AQId`?
fun is_structural: Bool do return false
# Write the subtree on stdout.
#
# Visit the subtree and display it with additional and useful information.
#
# By default, this displays all kind of nodes and the corresponding lines of codes.
#
# See `ASTDump` for details.
fun dump_tree(display_structural, display_line: nullable Bool)
do
var d = new ASTDump(display_structural or else true, display_line or else true)
d.enter_visit(self)
d.write_to(sys.stdout)
end
# Information to display on a node
#
# Refine this method to add additional information on each node type.
fun dump_info(v: ASTDump): String do return ""
# Parent of the node in the AST
var parent: nullable ANode = null
# The topmost ancestor of the element
# This just apply `parent` until the first one
fun root: ANode
do
var res = self
loop
var p = res.parent
if p == null then return res
res = p
end
end
# The most specific common parent between `self` and `other`
# Return null if the two node are unrelated (distinct root)
fun common_parent(other: ANode): nullable ANode
do
# First, get the same depth
var s: nullable ANode = self
var o: nullable ANode = other
var d = s.depth - o.depth
while d > 0 do
s = s.parent
d -= 1
end
while d < 0 do
o = o.parent
d += 1
end
assert o.depth == s.depth
# Second, go up until same in found
while s != o do
s = s.parent
o = o.parent
end
return s
end
# Number of nodes between `self` and the `root` of the AST
# ENSURE `self == self.root implies result == 0 `
# ENSURE `self != self.root implies result == self.parent.depth + 1`
fun depth: Int
do
var n = self
var res = 0
loop
var p = n.parent
if p == null then return res
n = p
res += 1
end
end
# Replace a child with an other node in the AST
private fun replace_child(old_child: ANode, new_child: nullable ANode) is abstract
# Detach a node from its parent
# Aborts if the node is not detachable. use `replace_with` instead
# REQUIRE: parent != null
# REQUIRE: is_detachable
# ENDURE: parent == null
fun detach
do
assert parent != null
parent.replace_child(self, null)
parent = null
end
# Replace itself with an other node in the AST
# REQUIRE: parent != null
# ENSURE: node.parent == old(parent)
# ENSURE: parent == null
fun replace_with(node: ANode)
do
assert parent != null
parent.replace_child(self, node)
parent = null
end
# Visit all nodes in order.
# Thus, call `v.enter_visit(e)` for each child `e`
fun visit_all(v: Visitor) is abstract
# Do a deep search and return an array of tokens that match a given text
fun collect_tokens_by_text(text: String): Array[Token]
do
var v = new CollectTokensByTextVisitor(text)
v.enter_visit(self)
return v.result
end
# Do a deep search and return an array of node that are annotated
# The attached node can be retrieved by two invocations of parent
fun collect_annotations_by_name(name: String): Array[AAnnotation]
do
var v = new CollectAnnotationsByNameVisitor(name)
v.enter_visit(self)
return v.result
end
end
src/parser/parser_nodes.nit:23,1--161,3
redef class ANode
# Visit the AST and computes advanced AST attributes on Tokens and Prod
# This also force a parent on the detashed tokens
fun parentize_tokens
do
var v = new PTokenVisitor
v.work(self)
end
end
src/astutil.nit:27,1--35,3
redef class ANode
private fun accept_simple_misc(v: SimpleMiscVisitor)
do
visit_all(v)
after_simple_misc(v)
end
private fun after_simple_misc(v: SimpleMiscVisitor) do end
end
src/frontend/simple_misc_analysis.nit:81,1--88,3
redef class ANode
private fun accept_literal(v: LiteralVisitor) do end
end
src/literal.nit:55,1--57,3
redef class ANode
# The indication that the node did not pass some semantic verifications.
#
# This simple flag is set by a given analysis to say that the node is broken and unusable in
# an execution.
# When a node status is set to broken, it is usually associated with a error message.
#
# If it is safe to do so, clients of the AST SHOULD just skip broken nodes in their processing.
# Clients that do not care about the executability (e.g. metrics) MAY still process the node or
# perform specific checks to determinate the validity of the node.
#
# Note that the broken status is not propagated to parent or children nodes.
# e.g. a broken expression used as argument does not make the whole call broken.
var is_broken = false is writable
redef fun dump_info(v) do
var res = super
if is_broken then
res += v.red("*broken*")
end
return res
end
end
src/modelbuilder_base.nit:531,1--553,3
redef class ANode
# Apply the forward analysis `v` to `self`.
fun accept_forward_analysis(v: ForwardAnalysis) do
v.current_inset = v.current_outset.clone
v.current_outset = v.current_inset.clone
v.insets[self] = v.current_inset
visit_all(v)
v.outsets[self] = v.current_outset
end
end
src/saf/saf_base.nit:130,1--140,3
redef class ANode
private fun accept_scope_visitor(v: ScopeVisitor)
do
visit_all(v)
end
end
src/semantize/scope.nit:246,1--251,3
redef class ANode
private fun accept_flow_visitor(v: FlowVisitor)
do
self.visit_all(v)
end
end
src/semantize/flow.nit:249,1--254,3
redef class ANode
# Start visit of `self` using a `PrettyPrinterVisitor`
private fun accept_pretty_printer(v: PrettyPrinterVisitor) is abstract
# Collect the length (in `Char`) of the node.
private fun collect_length: Int is abstract
# Is `self` printable in one line?
private fun is_inlinable: Bool do return true
# Force `self` to be rendered as a block.
private var force_block = false
# Does `self` have to be rendered as a block?
private fun must_be_block: Bool do return force_block
# Force `self` to be rendered as a line.
private var force_inline = false
# Does `self` have be rendered as a line?
private fun must_be_inline: Bool do
if parent != null and parent.must_be_inline then return true
return force_inline
end
# Does `self` was written in one line before transformation?
private fun was_inline: Bool is abstract
end
src/pretty.nit:319,1--346,3
redef class ANode
private fun accept_regex_visitor(v: RegexVisitor) do visit_all v
end
src/frontend/regex_phase.nit:46,1--48,3
redef class ANode
# Is this node annotated to be made serializable?
private fun is_serialize: Bool do return false
# Is this node annotated to not be made serializable?
private fun is_noserialize: Bool do return false
end
src/frontend/serialization_model_phase.nit:37,1--43,3
redef class ANode
# Apply a ReachingDefsAnalysis to `self`.
fun accept_reaching_defs(v: ReachingDefsAnalysis) do accept_forward_analysis(v)
end
src/saf/reaching_defs.nit:69,1--73,3
redef class ANode
private fun accept_local_var_visitor(v: LocalVarInitVisitor) do self.visit_all(v)
end
src/semantize/local_var_init.nit:105,1--107,3
redef class ANode
private fun accept_post_typing(v: TypeVisitor) do end
# An additional information message to explain the role of a child expression.
#
# The point of the method is to allow some kind of double dispatch so the parent
# choose how to describe its children.
private fun bad_expr_message(child: AExpr): nullable String do return null
end
src/semantize/typing.nit:951,1--959,3
redef class ANode
private fun accept_auto_super_init(v: AutoSuperInitVisitor) do end
end
src/semantize/auto_super_init.nit:186,1--188,3
redef class ANode
super Cloneable
redef fun clone: SELF
do
# By default the clone abort to avoid surprises
print "The clone method is not implemented for the `{self.class_name}` class"
abort
end
# Recursively validate a AST node.
# This ensure that location and parenting are defined and coherent.
#
# After complex low-level AST manipulation and construction,
# it is recommended to call it.
#
# Note: this just instantiate and run an `ASTValidationVisitor`.
fun validate
do
(new ASTValidationVisitor).enter_visit(self)
end
private fun accept_ast_validation(v: ASTValidationVisitor)
do
var parent = self.parent
var path = v.path
if path.length > 0 then
var path_parent = v.path.first
if parent == null then
self.parent = path_parent
#debug "PARENT: expected parent: {path_parent}"
v.seen.add(self)
else if parent != path_parent then
self.parent = path_parent
if v.seen.has(self) then
debug "DUPLICATE (NOTATREE): already seen node with parent {parent} now with {path_parent}."
else
v.seen.add(self)
debug "PARENT: expected parent: {path_parent}, got {parent}"
end
end
end
if not isset _location then
#debug "LOCATION: unlocated node {v.path.join(", ")}"
_location = self.parent.location
end
path.unshift(self)
visit_all(v)
path.shift
end
end
src/astbuilder.nit:892,1--944,3
redef class ANode
private fun accept_rapid_type_visitor(v: RapidTypeVisitor)
do
end
end
src/rapid_type_analysis.nit:538,1--542,3
redef class ANode
# Aborts the program with a message
# `v` is used to know if a colored message is displayed or not
fun fatal(v: NaiveInterpreter, message: String)
do
# Abort if there is a `catch` block
if v.catch_count > 0 then
v.last_error = new FatalError(message, self)
abort
end
if v.modelbuilder.toolcontext.opt_no_color.value then
sys.stderr.write("Runtime error: {message} ({location.file.filename}:{location.line_start})\n")
else
sys.stderr.write("{location}: Runtime error: {message}\n{location.colored_line("0;31")}\n")
sys.stderr.write(v.stack_trace)
sys.stderr.write("\n")
end
exit(1)
end
end
src/interpreter/naive_interpreter.nit:867,1--887,3
redef class ANode
private fun accept_string_finder(v: StringFinder) do end
end
src/frontend/i18n_phase.nit:126,1--128,3
redef class ANode
private fun full_transform_visitor(v: TransformVisitor)
do
visit_all(v)
accept_transform_visitor(v)
end
private fun accept_transform_visitor(v: TransformVisitor)
do
end
end
src/transform.nit:83,1--92,3
redef class ANode
private fun create_contracts(v: ContractsVisitor) do end
private fun check_callsite(v: CallSiteVisitor) do end
end
src/contracts.nit:251,1--254,3
redef class ANode
# Optionally creates a tag that encapsulate the AST element on HTML rendering
protected fun make_tag(v: HtmlightVisitor): nullable HTMLTag do return null
# Add aditionnal information on a child-token and return an additionnal HInfoBox on it
protected fun decorate_tag(v: HtmlightVisitor, res: HTMLTag, token: Token): nullable HInfoBox
do
#debug("no decoration for {token.inspect}")
#res.add_class("nc_error")
return null
end
# Return a optional infobox
fun infobox(v: HtmlightVisitor): nullable HInfoBox do return null
end
src/htmlight.nit:724,1--738,3
redef class ANode
private fun do_cloneable(v: CloneVisitor)do end
# Create a new clone of `self`
fun replace_clone
do
var self_clone = self.clone
replace_with(self.clone)
self_clone.location = location
#Call the `validate` method to set correctly the parents and the location
self_clone.validate
end
end
src/test_astbuilder.nit:48,1--60,3