nitc :: AVardeclExpr
var x: X = y
nitc :: AVardeclExpr :: _n_assign
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: _n_type
The declaration type of the local variablenitc :: AVardeclExpr :: _variable
The variable associated with the variable declarationnitc :: AVardeclExpr :: defaultinit
nitc :: AVardeclExpr :: n_assign
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: n_assign=
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: n_type
The declaration type of the local variablenitc :: AVardeclExpr :: n_type=
The declaration type of the local variablenitc :: AVardeclExpr :: variable
The variable associated with the variable declarationnitc :: AVardeclExpr :: variable=
The variable associated with the variable declarationnitc $ AVardeclExpr :: SELF
Type of this instance, automatically specialized in every classnitc :: local_var_init $ AVardeclExpr :: accept_local_var_visitor
nitc :: pretty $ AVardeclExpr :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: reaching_defs $ AVardeclExpr :: accept_reaching_defs
Apply a ReachingDefsAnalysis toself
.
nitc :: scope $ AVardeclExpr :: accept_scope_visitor
nitc :: transform $ AVardeclExpr :: accept_transform_visitor
var x = y
is replaced with x = y
nitc :: typing $ AVardeclExpr :: accept_typing
nitc :: htmlight $ AVardeclExpr :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: naive_interpreter $ AVardeclExpr :: expr
Evaluate the node as a possible expression.nitc :: ssa $ AVardeclExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: pretty $ AVardeclExpr :: is_inlinable
Isself
printable in one line?
nitc :: parser_prod $ AVardeclExpr :: n_annotations=
All the annotations attached directly to the nodenitc :: parser_prod $ AVardeclExpr :: n_assign=
The=
symbol (for the initial value)
nitc :: parser_prod $ AVardeclExpr :: n_expr=
The initial value, if anynitc :: parser_prod $ AVardeclExpr :: n_id=
The name of the local variablenitc :: parser_prod $ AVardeclExpr :: n_kwvar=
Thevar
keyword
nitc :: parser_prod $ AVardeclExpr :: n_type=
The declaration type of the local variablenitc :: variables_numbering $ AVardeclExpr :: numbering
Give a position to each variable declared in the node.nitc :: parser_prod $ AVardeclExpr :: replace_child
Replace a child with an other node in the ASTnitc :: java_compiler $ AVardeclExpr :: stmt
Try to compile self as a statementnitc :: abstract_compiler $ AVardeclExpr :: stmt
Try to compile self as a statementnitc :: parser_prod $ AVardeclExpr :: 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 :: 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 :: AVardeclExpr :: _n_assign
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: _n_type
The declaration type of the local variablenitc :: AExpr :: _vararg_decl
It indicates the number of arguments collected as a vararg.nitc :: AVardeclExpr :: _variable
The variable associated with the variable declarationnitc :: 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 :: 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 :: AExpr :: defaultinit
nitc :: AVardeclExpr :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: Prod :: 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 :: 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 :: AVardeclExpr :: n_assign
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: n_assign=
The=
symbol (for the initial value)
nitc :: AVardeclExpr :: n_type
The declaration type of the local variablenitc :: AVardeclExpr :: n_type=
The declaration type of the local variablecore :: 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 :: AVardeclExpr :: variable
The variable associated with the variable declarationnitc :: AVardeclExpr :: variable=
The variable associated with the variable declarationnitc :: 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?
# A declaration of a local variable. eg `var x: X = y`
class AVardeclExpr
super AExpr
# The `var` keyword
var n_kwvar: nullable TKwvar = null is writable
# The name of the local variable
var n_id: TId is writable, noinit
# The declaration type of the local variable
var n_type: nullable AType = null is writable
# The `=` symbol (for the initial value)
var n_assign: nullable TAssign = null is writable
# The initial value, if any
var n_expr: nullable AExpr = null is writable
end
src/parser/parser_nodes.nit:1859,1--1877,3
redef class AVardeclExpr
init init_avardeclexpr (
n_kwvar: nullable TKwvar,
n_id: nullable TId,
n_type: nullable AType,
n_assign: nullable TAssign,
n_expr: nullable AExpr,
n_annotations: nullable AAnnotations
)
do
_n_kwvar = n_kwvar
if n_kwvar != null then n_kwvar.parent = self
_n_id = n_id.as(not null)
n_id.parent = self
_n_type = n_type
if n_type != null then n_type.parent = self
_n_assign = n_assign
if n_assign != null then n_assign.parent = self
_n_expr = n_expr
if n_expr != null then n_expr.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_kwvar == old_child then
n_kwvar = new_child.as(nullable TKwvar)
return
end
if _n_id == old_child then
n_id = new_child.as(TId)
return
end
if _n_type == old_child then
n_type = new_child.as(nullable AType)
return
end
if _n_assign == old_child then
n_assign = new_child.as(nullable TAssign)
return
end
if _n_expr == old_child then
n_expr = new_child.as(nullable AExpr)
return
end
if _n_annotations == old_child then
n_annotations = new_child.as(nullable AAnnotations)
return
end
end
redef fun n_kwvar=(node)
do
_n_kwvar = node
if node != null then node.parent = self
end
redef fun n_id=(node)
do
_n_id = 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_assign=(node)
do
_n_assign = node
if node != null then node.parent = self
end
redef fun n_expr=(node)
do
_n_expr = node
if node != null then 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_kwvar)
v.enter_visit(_n_id)
v.enter_visit(_n_type)
v.enter_visit(_n_assign)
v.enter_visit(_n_expr)
v.enter_visit(_n_annotations)
end
end
src/parser/parser_prod.nit:2646,1--2739,3
redef class AVardeclExpr
# The variable associated with the variable declaration
var variable: nullable Variable
redef fun accept_scope_visitor(v)
do
super
var nid = self.n_id
var variable = new Variable(nid.text)
v.register_variable(nid, variable)
variable.warn_unread = true # wait for some read mark.
self.variable = variable
end
end
src/semantize/scope.nit:284,1--296,3
redef class AVardeclExpr
redef fun accept_pretty_printer(v) do
v.visit n_kwvar
v.adds
v.visit n_id
if n_type != null then
v.consume ":"
v.adds
v.visit n_type
end
if n_expr != null then
v.adds
v.consume "="
v.adds
v.visit n_expr
end
end
redef fun is_inlinable do return true
end
src/pretty.nit:1795,1--1816,3
redef class AVardeclExpr
redef fun accept_local_var_visitor(v)
do
super
# The variable is unset only if there is no initial value.
# Note: loops in initial value are not a problem
# Example:
#
# var foo = foo + 1 #-> Error during typing: "self.foo" unknown
#
# var foo
# foo = foo + 1 #-> Error here because 'foo' is possibly unset
if self.n_expr == null then
v.mark_is_unset(self, self.variable)
end
end
end
src/semantize/local_var_init.nit:109,1--126,3
redef class AVardeclExpr
redef fun accept_typing(v)
do
var variable = self.variable
if variable == null then return # Skip error
var ntype = self.n_type
var mtype: nullable MType
if ntype == null then
mtype = null
else
mtype = v.resolve_mtype(ntype)
if mtype == null then return # Skip error
end
var nexpr = self.n_expr
if nexpr != null then
if mtype != null then
var etype = v.visit_expr_subtype(nexpr, mtype)
if etype == mtype then
assert ntype != null
v.modelbuilder.advice(ntype, "useless-type", "Warning: useless type definition for variable `{variable.name}`")
end
else
mtype = v.visit_expr(nexpr)
if mtype == null then return # Skip error
end
end
var decltype = mtype
if mtype == null or mtype isa MNullType then
var objclass = v.get_mclass(self, "Object")
if objclass == null then return # skip error
decltype = objclass.mclass_type.as_nullable
if mtype == null then mtype = decltype
end
variable.declared_type = decltype
v.set_variable(self, variable, mtype)
#debug("var {variable}: {mtype}")
self.mtype = mtype
self.is_typed = true
end
end
src/semantize/typing.nit:1070,1--1115,3
redef class AVardeclExpr
redef fun generate_basic_blocks(ssa, old_block)
do
var decl = self.variable.as(not null)
# Add the corresponding variable to the enclosing mpropdef
ssa.propdef.variables.add(decl)
decl.original_variable = decl
decl.assignment_blocks.add(old_block)
old_block.variables.add(decl)
if self.n_expr != null then
self.variable.dep_exprs.add(self.n_expr.as(not null))
old_block = self.n_expr.generate_basic_blocks(ssa, old_block)
end
return old_block
end
end
src/ssa.nit:604,1--623,3
redef class AVardeclExpr
redef fun numbering(v, position)
do
# Attribute a position to this variable
self.variable.as(not null).position = position
position += 1
# Recursively continue to numbering the variables
position = v.numbering(self.n_expr, position)
# `position` is the next available position in the environment
return position
end
end
src/vm/variables_numbering.nit:178,1--191,3
redef class AVardeclExpr
# `var x = y` is replaced with `x = y`
#
# Declarations are only useful for scope rules
# Once names are associated with real objects, ther declaration become useless
# Therefore, if there is no initial value, then just ignore it
# Else, replace it with a simple assignment
redef fun accept_transform_visitor(v)
do
var nexpr = n_expr
if nexpr == null then
# do nothing
# note: not detached because the collection is currently under iteration
else
var nvar = v.builder.make_var_assign(self.variable.as(not null), nexpr)
replace_with(nvar)
end
end
end
src/transform.nit:124,1--142,3