nitc :: AIfexprExpr
if
expression (ternary conditional). eg. if true then 1 else 0
nitc :: AIfexprExpr :: _n_expr
The expression used as the condition of theif
nitc :: AIfexprExpr :: defaultinit
nitc :: AIfexprExpr :: init_aifexprexpr
nitc :: AIfexprExpr :: n_expr=
The expression used as the condition of theif
nitc $ AIfexprExpr :: SELF
Type of this instance, automatically specialized in every classnitc :: flow $ AIfexprExpr :: accept_flow_visitor
nitc :: transform $ AIfexprExpr :: accept_transform_visitor
is replaced withAIfExpr
nitc :: typing $ AIfexprExpr :: accept_typing
nitc :: simple_misc_analysis $ AIfexprExpr :: after_simple_misc
nitc :: naive_interpreter $ AIfexprExpr :: expr
Evaluate the node as a possible expression.nitc :: abstract_compiler $ AIfexprExpr :: expr
Try to compile self as an expressionnitc :: ssa $ AIfexprExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: parser_prod $ AIfexprExpr :: n_else=
The expression in theelse
part
nitc :: parser_prod $ AIfexprExpr :: n_expr=
The expression used as the condition of theif
nitc :: parser_prod $ AIfexprExpr :: n_then=
The expression in thethen
part
nitc :: variables_numbering $ AIfexprExpr :: numbering
Give a position to each variable declared in the node.nitc :: parser_prod $ AIfexprExpr :: replace_child
Replace a child with an other node in the ASTnitc :: parser_prod $ AIfexprExpr :: 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 :: AIfexprExpr :: _n_expr
The expression used as the condition of theif
nitc :: 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 :: 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 itcore :: Object :: defaultinit
nitc :: AIfexprExpr :: defaultinit
core :: Cloneable :: defaultinit
nitc :: ANode :: defaultinit
nitc :: Prod :: defaultinit
nitc :: AExpr :: 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 :: AIfexprExpr :: init_aifexprexpr
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 :: AIfexprExpr :: n_expr=
The expression used as the condition of theif
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 :: 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?
# A `if` expression (ternary conditional). eg. `if true then 1 else 0`
class AIfexprExpr
super AExpr
# The `if` keyword
var n_kwif: TKwif is writable, noinit
# The expression used as the condition of the `if`
var n_expr: AExpr is writable, noinit
# The `then` keyword
var n_kwthen: TKwthen is writable, noinit
# The expression in the `then` part
var n_then: AExpr is writable, noinit
# The `else` keyword
var n_kwelse: TKwelse is writable, noinit
# The expression in the `else` part
var n_else: AExpr is writable, noinit
end
src/parser/parser_nodes.nit:1980,1--2001,3
redef class AIfexprExpr
init init_aifexprexpr (
n_kwif: nullable TKwif,
n_expr: nullable AExpr,
n_kwthen: nullable TKwthen,
n_then: nullable AExpr,
n_kwelse: nullable TKwelse,
n_else: nullable AExpr
)
do
_n_kwif = n_kwif.as(not null)
n_kwif.parent = self
_n_expr = n_expr.as(not null)
n_expr.parent = self
_n_kwthen = n_kwthen.as(not null)
n_kwthen.parent = self
_n_then = n_then.as(not null)
n_then.parent = self
_n_kwelse = n_kwelse.as(not null)
n_kwelse.parent = self
_n_else = n_else.as(not null)
n_else.parent = self
end
redef fun replace_child(old_child: ANode, new_child: nullable ANode)
do
if _n_kwif == old_child then
n_kwif = new_child.as(TKwif)
return
end
if _n_expr == old_child then
n_expr = new_child.as(AExpr)
return
end
if _n_kwthen == old_child then
n_kwthen = new_child.as(TKwthen)
return
end
if _n_then == old_child then
n_then = new_child.as(AExpr)
return
end
if _n_kwelse == old_child then
n_kwelse = new_child.as(TKwelse)
return
end
if _n_else == old_child then
n_else = new_child.as(AExpr)
return
end
end
redef fun n_kwif=(node)
do
_n_kwif = node
node.parent = self
end
redef fun n_expr=(node)
do
_n_expr = node
node.parent = self
end
redef fun n_kwthen=(node)
do
_n_kwthen = node
node.parent = self
end
redef fun n_then=(node)
do
_n_then = node
node.parent = self
end
redef fun n_kwelse=(node)
do
_n_kwelse = node
node.parent = self
end
redef fun n_else=(node)
do
_n_else = node
node.parent = self
end
redef fun visit_all(v: Visitor)
do
v.enter_visit(_n_kwif)
v.enter_visit(_n_expr)
v.enter_visit(_n_kwthen)
v.enter_visit(_n_then)
v.enter_visit(_n_kwelse)
v.enter_visit(_n_else)
end
end
src/parser/parser_prod.nit:3112,1--3205,3
redef class AIfexprExpr
redef fun after_simple_misc(v)
do
n_expr.warn_parentheses(v)
end
end
src/frontend/simple_misc_analysis.nit:200,1--205,3
redef class AIfexprExpr
redef fun accept_flow_visitor(v)
do
var after_expr = v.visit_expr(self.n_expr)
v.current_flow_context = after_expr.when_true
v.enter_visit(self.n_then)
var after_then = v.current_flow_context
v.current_flow_context = after_expr.when_false
v.enter_visit(self.n_else)
var after_else = v.current_flow_context
v.make_merge_flow(after_then, after_else)
end
end
src/semantize/flow.nit:384,1--399,3
redef class AIfexprExpr
redef fun accept_typing(v)
do
v.visit_expr_bool(n_expr)
var t1 = v.visit_expr(n_then)
var t2 = v.visit_expr(n_else)
if t1 == null or t2 == null then
return # Skip error
end
var t = v.merge_types(self, [t1, t2])
if t == null then
v.error(self, "Type Error: ambiguous type `{t1}` vs `{t2}`.")
end
self.mtype = t
end
end
src/semantize/typing.nit:1278,1--1296,3
redef class AIfexprExpr
redef fun expr(v)
do
var res = v.new_var(self.mtype.as(not null))
var cond = v.expr_bool(self.n_expr)
v.add("if ({cond})\{")
v.assign(res, v.expr(self.n_then, null))
v.add("\} else \{")
v.assign(res, v.expr(self.n_else, null))
v.add("\}")
return res
end
end
src/compiler/abstract_compiler.nit:3860,1--3872,3
redef class AIfexprExpr
redef fun generate_basic_blocks(ssa, old_block)
do
# Terminate the previous block
old_block.last = self
# We start two new blocks if the if has two branches
var block_then = new BasicBlock
# Visit the test of the if
self.n_expr.generate_basic_blocks(ssa, old_block)
# Launch the recursion in two successors if they exist
old_block.link(block_then)
block_then.first = self.n_then
block_then.last = self.n_then
self.n_then.generate_basic_blocks(ssa, block_then)
var block_else = new BasicBlock
old_block.link(block_else)
block_else.first = self.n_else
block_else.last = self.n_else
self.n_else.generate_basic_blocks(ssa, block_else)
# Create a new BasicBlock to represent the two successor
# branches of the if
var new_block = new BasicBlock
new_block.first = self
new_block.last = self
block_then.link(new_block)
# The new block needs to be filled by the caller
new_block.need_update = true
block_else.link(new_block)
return new_block
end
end
src/ssa.nit:1007,1--1049,3
redef class AIfexprExpr
redef fun numbering(v, position)
do
# Attribute numbers separetely for the two branches
var pos = v.numbering(self.n_then, position)
var pos1 = v.numbering(self.n_else, position)
if pos > pos1 then
return pos
else
return pos1
end
end
end
src/vm/variables_numbering.nit:218,1--231,3
redef class AIfexprExpr
# is replaced with `AIfExpr`
# Expression if and statement-if use two distinct classes for historical reasons
# However, on can replace the `AIfexprExpr` with the simpler `AIfExpr`
redef fun accept_transform_visitor(v)
do
var nif = v.builder.make_if(n_expr, self.mtype)
nif.n_then.add(n_then)
nif.n_else.add(n_else)
replace_with(nif)
end
end
src/transform.nit:144,1--156,3