for
statementnitc :: AForExpr :: _break_mark
The break escape mark associated with the 'for'nitc :: AForExpr :: _continue_mark
The continue escape mark associated with the 'for'nitc :: AForExpr :: break_mark
The break escape mark associated with the 'for'nitc :: AForExpr :: break_mark=
The break escape mark associated with the 'for'nitc :: AForExpr :: continue_mark
The continue escape mark associated with the 'for'nitc :: AForExpr :: continue_mark=
The continue escape mark associated with the 'for'nitc :: AForExpr :: defaultinit
nitc :: AForExpr :: init_aforexpr
nitc :: flow $ AForExpr :: accept_flow_visitor
nitc :: saf_base $ AForExpr :: accept_forward_analysis
Apply the forward analysisv
to self
.
nitc :: pretty $ AForExpr :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: reaching_defs $ AForExpr :: accept_reaching_defs
Apply a ReachingDefsAnalysis toself
.
nitc :: scope $ AForExpr :: accept_scope_visitor
nitc :: typing $ AForExpr :: accept_typing
nitc :: simple_misc_analysis $ AForExpr :: after_simple_misc
nitc :: ssa $ AForExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: pretty $ AForExpr :: loop_block
nitc :: saf_base $ AForExpr :: loop_block
The block contained by this loop.nitc :: pretty $ AForExpr :: loop_label
nitc :: variables_numbering $ AForExpr :: numbering
Give a position to each variable declared in the node.nitc :: parser_prod $ AForExpr :: replace_child
Replace a child with an other node in the ASTnitc :: naive_interpreter $ AForExpr :: stmt
Evaluate the node as a statement.nitc :: abstract_compiler $ AForExpr :: stmt
Try to compile self as a statementnitc :: AExpr :: _after_flow_context
The flow after the full evaluation of the expression/statementnitc :: AForExpr :: _break_mark
The break escape mark associated with the 'for'nitc :: AExpr :: _comprehension
Is non-null ifself
is a leaf of a comprehension array construction.
nitc :: AForExpr :: _continue_mark
The continue escape mark associated with the 'for'nitc :: Prod :: _first_location
Location on the first token after the start of a productionnitc :: Prod :: _first_token
The first token of the production in the ASTnitc :: AExpr :: _implicit_cast_to
If required, the following implicit cast.as(XXX)
nitc :: ANode :: _is_broken
The indication that the node did not pass some semantic verifications.nitc :: Prod :: _last_token
The last token of the production in the ASTnitc :: Prod :: _n_annotations
All the annotations attached directly to the nodenitc :: ALabelable :: _n_label
The associated label declatationnitc :: AExpr :: _vararg_decl
It indicates the number of arguments collected as a vararg.nitc :: AExpr :: _variable_cache
nitc :: ANode :: accept_ast_validation
nitc :: ANode :: accept_auto_super_init
nitc :: AExpr :: accept_explain_assert
Fillv
to explain this node if the parent assert fails
nitc :: ANode :: accept_flow_visitor
nitc :: ANode :: accept_forward_analysis
Apply the forward analysisv
to self
.
nitc :: ANode :: accept_literal
nitc :: ADoBlockHelper :: accept_loop_forward_analysis
Factorize loop forward analysis.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 :: AExpr :: accept_typing
nitc :: AExpr :: after_flow_context
The flow after the full evaluation of the expression/statementnitc :: AExpr :: after_flow_context=
The flow after the full evaluation of the expression/statementnitc :: ANode :: after_simple_misc
nitc :: AExpr :: allocate_mtype
Make themtype
of the expression live
nitc :: ANode :: bad_expr_message
An additional information message to explain the role of a child expression.nitc :: AForExpr :: break_mark
The break escape mark associated with the 'for'nitc :: AForExpr :: break_mark=
The break escape mark associated with the 'for'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 :: Prod :: collect_comments
Collect allTComment
contained in the production
nitc :: 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 :: AExpr :: comprehension
Is non-null ifself
is a leaf of a comprehension array construction.
nitc :: AExpr :: comprehension=
Is non-null ifself
is a leaf of a comprehension array construction.
nitc :: AForExpr :: continue_mark
The continue escape mark associated with the 'for'nitc :: AForExpr :: continue_mark=
The continue escape mark associated with the 'for'nitc :: ANode :: create_contracts
nitc :: ANode :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: ADoBlockHelper :: defaultinit
nitc :: AExpr :: defaultinit
nitc :: ALabelable :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: AForExpr :: defaultinit
nitc :: Prod :: defaultinit
nitc :: ALoopHelper :: defaultinit
nitc :: ANode :: defaultinit
nitc :: AExpr :: detach_with_placeholder
Thedetach
method completely remove the node in the parent.
nitc :: ANode :: do_cloneable
nitc :: Prod :: first_location
Location on the first token after the start of a productionnitc :: Prod :: first_location=
Location on the first token after the start of a productionnitc :: Prod :: first_token
The first token of the production in the ASTnitc :: Prod :: first_token=
The first token of the production in the ASTnitc :: 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 :: AExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: Prod :: get_annotations
Return all its annotations of a given name in the order of their declarationnitc :: Prod :: get_single_annotation
Try to get its single annotation with a given namenitc :: ANode :: hot_location
The location of the important part of the node (identifier or whatever)nitc :: AExpr :: implicit_cast_to
If required, the following implicit cast.as(XXX)
nitc :: AExpr :: implicit_cast_to=
If required, the following implicit cast.as(XXX)
nitc :: AForExpr :: init_aforexpr
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 :: Prod :: last_token
The last token of the production in the ASTnitc :: Prod :: last_token=
The last token of the production in the ASTnitc :: ALoopHelper :: loop_block
nitc :: ADoBlockHelper :: loop_block
The block contained by this loop.nitc :: ADoBlockHelper :: loop_fix_point
Lookup fix point for this loop.nitc :: ALoopHelper :: loop_label
nitc :: AExpr :: make_var_read
Return a new variable read that contains the value of the expressionnitc :: 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 :: Prod :: n_annotations
All the annotations attached directly to the nodenitc :: Prod :: n_annotations=
All the annotations attached directly to the nodenitc :: ALabelable :: n_label=
The associated label declatationcore :: 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 :: Prod :: start_token
The token where the production really start (skipping ADoc).nitc :: AExpr :: vararg_decl
It indicates the number of arguments collected as a vararg.nitc :: AExpr :: vararg_decl=
It indicates the number of arguments collected as a vararg.nitc :: AExpr :: variable_cache
nitc :: AExpr :: variable_cache=
nitc :: ALoopHelper :: visit_loop_block
nitc :: ALoopHelper :: visit_loop_inline
nitc :: AExpr :: warn_parentheses
Warn in case of superfluous parenthesesnitc :: ANode :: was_inline
Doesself
was written in one line before transformation?
# A `for` statement
class AForExpr
super AExpr
super ALabelable
# The `for` keyword
var n_kwfor: TKwfor is writable, noinit
# The list of groups to iterate
var n_groups = new ANodes[AForGroup](self)
# The `do` keyword
var n_kwdo: TKwdo is writable, noinit
# The body of the loop
var n_block: nullable AExpr = null is writable
end
src/parser/parser_nodes.nit:2033,1--2049,3
redef class AForExpr
init init_aforexpr (
n_kwfor: nullable TKwfor,
n_groups: Collection[Object], # Should be Collection[AForGroup]
n_kwdo: nullable TKwdo,
n_block: nullable AExpr,
n_label: nullable ALabel
)
do
_n_kwfor = n_kwfor.as(not null)
n_kwfor.parent = self
self.n_groups.unsafe_add_all(n_groups)
_n_kwdo = n_kwdo.as(not null)
n_kwdo.parent = self
_n_block = n_block
if n_block != null then n_block.parent = self
_n_label = n_label
if n_label != null then n_label.parent = self
end
redef fun replace_child(old_child: ANode, new_child: nullable ANode)
do
if _n_kwfor == old_child then
n_kwfor = new_child.as(TKwfor)
return
end
if n_groups.replace_child(old_child, new_child) then return
if _n_kwdo == old_child then
n_kwdo = new_child.as(TKwdo)
return
end
if _n_block == old_child then
n_block = new_child.as(nullable AExpr)
return
end
if _n_label == old_child then
n_label = new_child.as(nullable ALabel)
return
end
end
redef fun n_kwfor=(node)
do
_n_kwfor = node
node.parent = self
end
redef fun n_kwdo=(node)
do
_n_kwdo = node
node.parent = self
end
redef fun n_block=(node)
do
_n_block = node
if node != null then node.parent = self
end
redef fun n_label=(node)
do
_n_label = node
if node != null then node.parent = self
end
redef fun visit_all(v: Visitor)
do
v.enter_visit(_n_kwfor)
n_groups.visit_all(v)
v.enter_visit(_n_kwdo)
v.enter_visit(_n_block)
v.enter_visit(_n_label)
end
end
src/parser/parser_prod.nit:3342,1--3413,3
redef class AForExpr
redef fun after_simple_misc(v)
do
v.check_do_expr(n_block)
end
end
src/frontend/simple_misc_analysis.nit:172,1--177,3
redef class AForExpr
# The break escape mark associated with the 'for'
var break_mark: nullable EscapeMark
# The continue escape mark associated with the 'for'
var continue_mark: nullable EscapeMark
redef fun accept_scope_visitor(v)
do
for g in n_groups do
v.enter_visit(g.n_expr)
end
# Protect automatic variables
v.scopes.unshift(new Scope)
for g in n_groups do
# Create the automatic variables
var variables = new Array[Variable]
g.variables = variables
for nid in g.n_ids do
var va = new Variable(nid.text)
v.register_variable(nid, va)
variables.add(va)
end
end
var escapemark = v.make_escape_mark(n_label, true)
self.break_mark = escapemark
self.continue_mark = escapemark.continue_mark
v.enter_visit_block(n_block, escapemark)
v.shift_scope
end
end
src/semantize/scope.nit:410,1--444,3
redef class AForExpr
super ADoBlockHelper
redef fun loop_block do return self.n_block
redef fun accept_forward_analysis(v) do
for n_group in n_groups do
v.enter_visit(n_group.n_expr)
end
accept_loop_forward_analysis(v)
end
end
src/saf/saf_base.nit:225,1--236,3
redef class AForExpr
redef fun accept_flow_visitor(v)
do
for g in n_groups do
v.enter_visit(g.n_expr)
end
var before_loop = v.make_sub_flow
v.enter_visit(self.n_block)
var after_block = v.current_flow_context
before_loop.add_loop(after_block)
v.merge_continues_to(before_loop, self.continue_mark)
v.make_merge_flow(v.current_flow_context, before_loop)
v.merge_breaks(self.break_mark)
end
end
src/semantize/flow.nit:437,1--456,3
redef class AForExpr
super ALoopHelper
redef fun loop_block do return n_block
redef fun loop_label do return n_label
redef fun accept_pretty_printer(v) do
var can_inline = v.can_inline(self)
v.visit n_kwfor
v.adds
for n_group in n_groups do
v.visit n_group
if n_group != n_groups.last then v.add ", "
end
v.adds
v.visit n_kwdo
if can_inline then visit_loop_inline v else visit_loop_block v
end
end
src/pretty.nit:1511,1--1532,3
redef class AForExpr
redef fun accept_reaching_defs(v) do
# add variables from `for` declaration
for n_group in n_groups do
var variables = n_group.variables
if variables == null then continue
for variable in variables do v.gen(variable, n_group.location)
end
super
# remove variables from `for` declaration
for n_group in n_groups do
var variables = n_group.variables
if variables == null then continue
for variable in variables do v.kill(variable)
end
end
end
src/saf/reaching_defs.nit:99,1--115,3
redef class AForExpr
redef fun accept_typing(v)
do
v.has_loop = true
for g in n_groups do
var mtype = v.visit_expr(g.n_expr)
if mtype == null then return
g.do_type_iterator(v, mtype)
if g.is_broken then is_broken = true
end
v.visit_stmt(n_block)
self.mtype = n_block.mtype
self.is_typed = true
end
end
src/semantize/typing.nit:1326,1--1343,3
redef class AForExpr
redef fun stmt(v)
do
var iters = new Array[Instance]
for g in n_groups do
var col = v.expr(g.n_expr)
if col == null then return
if col.is_null then fatal(v, "Receiver is null")
var iter = v.callsite(g.method_iterator, [col]).as(not null)
iters.add iter
end
loop
for g in n_groups, iter in iters do
var isok = v.callsite(g.method_is_ok, [iter]).as(not null)
if not isok.is_true then break label
if g.variables.length == 1 then
var item = v.callsite(g.method_item, [iter]).as(not null)
#self.debug("item {item}")
v.write_variable(g.variables.first, item)
else if g.variables.length == 2 then
var key = v.callsite(g.method_key, [iter]).as(not null)
v.write_variable(g.variables[0], key)
var item = v.callsite(g.method_item, [iter]).as(not null)
v.write_variable(g.variables[1], item)
else
abort
end
end
v.stmt(self.n_block)
if v.is_escape(self.break_mark) then break
v.is_escape(self.continue_mark) # Clear the break
if v.is_escaping then break
for g in n_groups, iter in iters do
v.callsite(g.method_next, [iter])
end
end label
for g in n_groups, iter in iters do
var method_finish = g.method_finish
if method_finish != null then
v.callsite(method_finish, [iter])
end
end
end
end
src/interpreter/naive_interpreter.nit:1881,1--1927,3
redef class AForExpr
redef fun generate_basic_blocks(ssa, old_block)
do
old_block.last = self
# The beginning of the block is the first instruction
var block = new BasicBlock
block.first = self.n_groups.first.n_expr
block.last = self.n_block.as(not null)
for g in n_groups do
# Visit the test of the if
g.n_expr.generate_basic_blocks(ssa, block)
# Collect the variables declared in the for
for v in g.variables do
ssa.propdef.variables.add(v)
end
end
old_block.link(block)
block.link(old_block)
var new_block = new BasicBlock
new_block.first = self
new_block.last = self
new_block.need_update = true
return new_block
end
end
src/ssa.nit:1113,1--1145,3
redef class AForExpr
redef fun numbering(v, position)
do
for g in n_groups do
# Give a position to each variable declared in the header of the for
if g.variables.length == 1 then
g.variables.first.position = position
g.variables[0].position = position
position += 1
else if g.variables.length == 2 then
g.variables[0].position = position
position += 1
g.variables[1].position = position
position += 1
end
position = v.numbering(self.n_block, position)
end
return position
end
end
src/vm/variables_numbering.nit:254,1--273,3
redef class AForExpr
redef fun accept_transform_visitor(v)
do
var escapemark = self.break_mark
assert escapemark != null
# Main block that will contain the whole for and will replace `self`
var nblock = v.builder.make_block
# Part before the loop
var before = v.builder.make_block
nblock.add before
# The loop
var nloop = v.builder.make_loop
nloop.break_mark = escapemark
nblock.add nloop
# Part before the body inside the loop
var begin = v.builder.make_block
nloop.add begin
# The `do` block with then user code
var ndo = v.builder.make_do
ndo.break_mark = escapemark.continue_mark
nloop.add ndo
ndo.add self.n_block.as(not null)
# Fill up each part
for g in n_groups do
g.transform_in(v, before, begin, nloop, nblock, escapemark)
end
replace_with(nblock)
end
end
src/transform.nit:210,1--246,3
redef class AForExpr
redef fun stmt(v)
do
for g in n_groups do
var cl = v.expr(g.n_expr, null)
var it_meth = g.method_iterator
assert it_meth != null
var it = v.compile_callsite(it_meth, [cl])
assert it != null
g.it = it
end
v.add("for(;;) \{")
for g in n_groups do
var it = g.it
var isok_meth = g.method_is_ok
assert isok_meth != null
var ok = v.compile_callsite(isok_meth, [it])
assert ok != null
v.add("if(!{ok}) break;")
if g.variables.length == 1 then
var item_meth = g.method_item
assert item_meth != null
var i = v.compile_callsite(item_meth, [it])
assert i != null
v.assign(v.variable(g.variables.first), i)
else if g.variables.length == 2 then
var key_meth = g.method_key
assert key_meth != null
var i = v.compile_callsite(key_meth, [it])
assert i != null
v.assign(v.variable(g.variables[0]), i)
var item_meth = g.method_item
assert item_meth != null
i = v.compile_callsite(item_meth, [it])
assert i != null
v.assign(v.variable(g.variables[1]), i)
else
abort
end
end
v.stmt(self.n_block)
v.add_escape_label(continue_mark)
for g in n_groups do
var next_meth = g.method_next
assert next_meth != null
v.compile_callsite(next_meth, [g.it])
end
v.add("\}")
v.add_escape_label(break_mark)
for g in n_groups do
var method_finish = g.method_finish
if method_finish != null then
# TODO: Find a way to call this also in long escape (e.g. return)
v.compile_callsite(method_finish, [g.it])
end
end
end
end
src/compiler/abstract_compiler.nit:3929,1--3987,3