nitc :: AArrayExpr
[x,y,z]
nitc :: AArrayExpr :: _element_mtype
The element of each typenitc :: AArrayExpr :: _n_type
The type of the element of the array (if any)nitc :: AArrayExpr :: _nnew
nitc :: AArrayExpr :: _push_callsite
Thepush
method on arrays
nitc :: AArrayExpr :: _with_capacity_callsite
Thewith_capacity
method on Array
nitc :: AArrayExpr :: defaultinit
nitc :: AArrayExpr :: element_mtype=
The element of each typenitc :: AArrayExpr :: init_aarrayexpr
nitc :: AArrayExpr :: n_type
The type of the element of the array (if any)nitc :: AArrayExpr :: n_type=
The type of the element of the array (if any)nitc :: AArrayExpr :: nnew
nitc :: AArrayExpr :: nnew=
nitc :: AArrayExpr :: push_callsite=
Thepush
method on arrays
nitc :: AArrayExpr :: set_comprehension
Set thatself
is a part of comprehension array na
nitc :: AArrayExpr :: with_capacity_callsite
Thewith_capacity
method on Array
nitc :: AArrayExpr :: with_capacity_callsite=
Thewith_capacity
method on Array
nitc $ AArrayExpr :: SELF
Type of this instance, automatically specialized in every classnitc :: pretty $ AArrayExpr :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: rapid_type_analysis $ AArrayExpr :: accept_rapid_type_visitor
nitc :: typing $ AArrayExpr :: accept_typing
nitc :: naive_interpreter $ AArrayExpr :: expr
Evaluate the node as a possible expression.nitc :: abstract_compiler $ AArrayExpr :: expr
Try to compile self as an expressionnitc :: transform $ AArrayExpr :: full_transform_visitor
[x,y]
is replaced with
nitc :: ssa $ AArrayExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: parser_prod $ AArrayExpr :: n_annotations=
All the annotations attached directly to the nodenitc :: parser_prod $ AArrayExpr :: n_type=
The type of the element of the array (if any)nitc :: variables_numbering $ AArrayExpr :: numbering
Give a position to each variable declared in the node.nitc :: parser_prod $ AArrayExpr :: replace_child
Replace a child with an other node in the ASTnitc :: parser_prod $ AArrayExpr :: visit_all
Visit all nodes in order.nitc :: AExpr :: _after_flow_context
The flow after the full evaluation of the expression/statementnitc :: AExpr :: _comprehension
Is non-null ifself
is a leaf of a comprehension array construction.
nitc :: AArrayExpr :: _element_mtype
The element of each typenitc :: 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 :: AArrayExpr :: _n_type
The type of the element of the array (if any)nitc :: AArrayExpr :: _nnew
nitc :: AArrayExpr :: _push_callsite
Thepush
method on arrays
nitc :: AExpr :: _vararg_decl
It indicates the number of arguments collected as a vararg.nitc :: AExpr :: _variable_cache
nitc :: AArrayExpr :: _with_capacity_callsite
Thewith_capacity
method on Array
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 :: 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 :: 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 :: ANode :: create_contracts
nitc :: ANode :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: ANode :: defaultinit
nitc :: AExpr :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: AArrayExpr :: defaultinit
nitc :: Prod :: defaultinit
nitc :: AExpr :: detach_with_placeholder
Thedetach
method completely remove the node in the parent.
nitc :: ANode :: do_cloneable
nitc :: AArrayExpr :: element_mtype=
The element of each typenitc :: 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 :: AArrayExpr :: init_aarrayexpr
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 :: 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 :: AArrayExpr :: n_type
The type of the element of the array (if any)nitc :: AArrayExpr :: n_type=
The type of the element of the array (if any)core :: Object :: native_class_name
The class name of the object in CString format.nitc :: AArrayExpr :: nnew
nitc :: AArrayExpr :: nnew=
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 :: AArrayExpr :: push_callsite=
Thepush
method on arrays
nitc :: 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 :: AArrayExpr :: set_comprehension
Set thatself
is a part of comprehension array na
nitc :: 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 :: AExpr :: warn_parentheses
Warn in case of superfluous parenthesesnitc :: ANode :: was_inline
Doesself
was written in one line before transformation?
nitc :: AArrayExpr :: with_capacity_callsite
Thewith_capacity
method on Array
nitc :: AArrayExpr :: with_capacity_callsite=
Thewith_capacity
method on Array
# A literal array. eg. `[x,y,z]`
class AArrayExpr
super AExpr
# The opening bracket `[`
var n_obra: TObra is writable, noinit
# The elements of the array
var n_exprs = new ANodes[AExpr](self)
# The type of the element of the array (if any)
var n_type: nullable AType = null is writable
# The closing bracket `]`
var n_cbra: TCbra is writable, noinit
end
src/parser/parser_nodes.nit:2595,1--2610,3
redef class AArrayExpr
init init_aarrayexpr (
n_obra: nullable TObra,
n_exprs: Collection[Object], # Should be Collection[AExpr]
n_type: nullable AType,
n_cbra: nullable TCbra,
n_annotations: nullable AAnnotations
)
do
_n_obra = n_obra.as(not null)
n_obra.parent = self
self.n_exprs.unsafe_add_all(n_exprs)
_n_type = n_type
if n_type != null then n_type.parent = self
_n_cbra = n_cbra.as(not null)
n_cbra.parent = self
_n_annotations = n_annotations
if n_annotations != null then n_annotations.parent = self
end
redef fun replace_child(old_child: ANode, new_child: nullable ANode)
do
if _n_obra == old_child then
n_obra = new_child.as(TObra)
return
end
if n_exprs.replace_child(old_child, new_child) then return
if _n_type == old_child then
n_type = new_child.as(nullable AType)
return
end
if _n_cbra == old_child then
n_cbra = new_child.as(TCbra)
return
end
if _n_annotations == old_child then
n_annotations = new_child.as(nullable AAnnotations)
return
end
end
redef fun n_obra=(node)
do
_n_obra = node
node.parent = self
end
redef fun n_type=(node)
do
_n_type = node
if node != null then node.parent = self
end
redef fun n_cbra=(node)
do
_n_cbra = node
node.parent = self
end
redef fun n_annotations=(node)
do
_n_annotations = node
if node != null then node.parent = self
end
redef fun visit_all(v: Visitor)
do
v.enter_visit(_n_obra)
n_exprs.visit_all(v)
v.enter_visit(_n_type)
v.enter_visit(_n_cbra)
v.enter_visit(_n_annotations)
end
end
src/parser/parser_prod.nit:6336,1--6407,3
redef class AArrayExpr
# The `with_capacity` method on Array
var with_capacity_callsite: nullable CallSite
# The `push` method on arrays
var push_callsite: nullable CallSite
# The element of each type
var element_mtype: nullable MType
# Set that `self` is a part of comprehension array `na`
# If `self` is a `for`, or a `if`, then `set_comprehension` is recursively applied.
private fun set_comprehension(n: nullable AExpr)
do
if n == null then
return
else if n isa AForExpr then
set_comprehension(n.n_block)
else if n isa AIfExpr then
set_comprehension(n.n_then)
set_comprehension(n.n_else)
else
# is a leave
n.comprehension = self
end
end
redef fun accept_typing(v)
do
var mtype: nullable MType = null
var ntype = self.n_type
if ntype != null then
mtype = v.resolve_mtype(ntype)
if mtype == null then return # Skip error
end
var mtypes = new Array[nullable MType]
var useless = false
for e in self.n_exprs do
var t = v.visit_expr(e)
if t == null then
return # Skip error
end
set_comprehension(e)
if mtype != null then
if v.check_subtype(e, t, mtype, false) == null then return # Forward error
if t == mtype then useless = true
else
mtypes.add(t)
end
end
if mtype == null then
# Ensure monotony for type adaptation on loops
if self.element_mtype != null then mtypes.add self.element_mtype
mtype = v.merge_types(self, mtypes)
end
if mtype == null or mtype isa MNullType then
v.error(self, "Type Error: ambiguous array type {mtypes.join(" ")}")
return
end
if useless then
assert ntype != null
v.display_warning(ntype, "useless-type", "Warning: useless type declaration `{mtype}` in literal Array since it can be inferred from the elements type.")
end
self.element_mtype = mtype
var mclass = v.get_mclass(self, "Array")
if mclass == null then return # Forward error
var array_mtype = mclass.get_mtype([mtype])
with_capacity_callsite = v.build_callsite_by_name(self, array_mtype, "with_capacity", false)
push_callsite = v.build_callsite_by_name(self, array_mtype, "push", false)
self.mtype = array_mtype
end
end
src/semantize/typing.nit:1700,1--1774,3
redef class AArrayExpr
redef fun accept_rapid_type_visitor(v)
do
var mtype = self.mtype.as(MClassType)
v.add_type(mtype)
var native = v.analysis.mainmodule.native_array_type(mtype.arguments.first)
v.add_type(native)
mtype = v.cleanup_type(mtype).as(not null)
var prop = v.get_method(mtype, "with_native")
v.add_monomorphic_send(mtype, prop)
v.add_callsite(with_capacity_callsite)
v.add_callsite(push_callsite)
end
end
src/rapid_type_analysis.nit:576,1--589,3
redef class AArrayExpr
redef fun expr(v)
do
var val = new Array[Instance]
var old_comprehension = v.frame.comprehension
v.frame.comprehension = val
for nexpr in self.n_exprs do
if nexpr isa AForExpr then
v.stmt(nexpr)
else
var i = v.expr(nexpr)
if i == null then return null
val.add(i)
end
end
v.frame.comprehension = old_comprehension
var mtype = v.unanchor_type(self.mtype.as(not null)).as(MClassType)
var elttype = mtype.arguments.first
return v.array_instance(val, elttype)
end
end
src/interpreter/naive_interpreter.nit:2063,1--2083,3
redef class AArrayExpr
redef fun generate_basic_blocks(ssa, old_block)
do
for nexpr in self.n_exprs do
old_block = nexpr.generate_basic_blocks(ssa, old_block)
end
return old_block
end
end
src/ssa.nit:764,1--773,3
redef class AArrayExpr
redef fun expr(v)
do
var mtype = self.element_mtype.as(not null)
var array = new Array[RuntimeVariable]
var res = v.array_instance(array, mtype)
var old_comprehension = v.frame.comprehension
v.frame.comprehension = res
for nexpr in self.n_exprs do
v.stmt(nexpr)
end
v.frame.comprehension = old_comprehension
return res
end
end
src/compiler/abstract_compiler.nit:4133,1--4149,3
redef class AArrayExpr
# `[x,y]` is replaced with
#
# ~~~nitish
# var t = new Array[X].with_capacity(2)
# t.add(x)
# t.add(y)
# t
# ~~~
redef fun full_transform_visitor(v)
do
if is_broken then return # Skip broken
var nblock = v.builder.make_block
var nnew = v.builder.make_new(with_capacity_callsite.as(not null), [v.builder.make_int(n_exprs.length)])
self.nnew = nnew
nblock.add nnew
super
for nexpr in self.n_exprs do
nblock.add nexpr
end
var nres = nnew.make_var_read
nblock.add nres
replace_with(nblock)
end
private var nnew: ANewExpr is noinit
end
src/transform.nit:361,1--393,3