x isa T
nitc :: AIsaExpr :: cast_type=
The static type to cast to.nitc :: AIsaExpr :: defaultinit
nitc :: AIsaExpr :: init_aisaexpr
nitc :: explain_assert $ AIsaExpr :: accept_explain_assert
Fillv
to explain this node if the parent assert fails
nitc :: flow $ AIsaExpr :: accept_flow_visitor
nitc :: typing $ AIsaExpr :: accept_post_typing
nitc :: pretty $ AIsaExpr :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: rapid_type_analysis $ AIsaExpr :: accept_rapid_type_visitor
nitc :: typing $ AIsaExpr :: accept_typing
nitc :: java_compiler $ AIsaExpr :: expr
Try to compile self as an expressionnitc :: abstract_compiler $ AIsaExpr :: expr
Try to compile self as an expressionnitc :: naive_interpreter $ AIsaExpr :: expr
Evaluate the node as a possible expression.nitc :: vm_optimizations $ AIsaExpr :: expr
Evaluate the node as a possible expression.nitc :: ssa $ AIsaExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: parser_prod $ AIsaExpr :: replace_child
Replace a child with an other node in the ASTnitc :: 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 :: 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 :: AIsaExpr :: cast_type=
The static type to cast to.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 :: ABoolExpr :: defaultinit
nitc :: AExpr :: defaultinit
core :: Cloneable :: defaultinit
nitc :: Prod :: defaultinit
core :: Object :: defaultinit
nitc :: AIsaExpr :: 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 :: AIsaExpr :: init_aisaexpr
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 nodecore :: 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 type-ckeck expression. eg `x isa T`
class AIsaExpr
super ABoolExpr
# The expression to check
var n_expr: AExpr is writable, noinit
# The `isa` keyword
var n_kwisa: TKwisa is writable, noinit
# The destination type to check to
var n_type: AType is writable, noinit
end
src/parser/parser_nodes.nit:2270,1--2282,3
redef class AIsaExpr
init init_aisaexpr (
n_expr: nullable AExpr,
n_kwisa: nullable TKwisa,
n_type: nullable AType
)
do
_n_expr = n_expr.as(not null)
n_expr.parent = self
_n_kwisa = n_kwisa.as(not null)
n_kwisa.parent = self
_n_type = n_type.as(not null)
n_type.parent = self
end
redef fun replace_child(old_child: ANode, new_child: nullable ANode)
do
if _n_expr == old_child then
n_expr = new_child.as(AExpr)
return
end
if _n_kwisa == old_child then
n_kwisa = new_child.as(TKwisa)
return
end
if _n_type == old_child then
n_type = new_child.as(AType)
return
end
end
redef fun n_expr=(node)
do
_n_expr = node
node.parent = self
end
redef fun n_kwisa=(node)
do
_n_kwisa = node
node.parent = self
end
redef fun n_type=(node)
do
_n_type = node
node.parent = self
end
redef fun visit_all(v: Visitor)
do
v.enter_visit(_n_expr)
v.enter_visit(_n_kwisa)
v.enter_visit(_n_type)
end
end
src/parser/parser_prod.nit:4404,1--4458,3
redef class AIsaExpr
redef fun accept_flow_visitor(v)
do
super
v.make_sub_true_false_flow
end
end
src/semantize/flow.nit:557,1--563,3
redef class AIsaExpr
# The static type to cast to.
# (different from the static type of the expression that is `Bool`).
var cast_type: nullable MType
redef fun accept_typing(v)
do
v.visit_expr(n_expr)
var mtype = v.resolve_mtype(n_type)
self.cast_type = mtype
var variable = self.n_expr.its_variable
if variable != null then
var orig = self.n_expr.mtype
#var from = if orig != null then orig.to_s else "invalid"
#var to = if mtype != null then mtype.to_s else "invalid"
#debug("adapt {variable}: {from} -> {to}")
var thentype = v.intersect_types(self, orig, mtype)
if thentype != orig then
self.after_flow_context.when_true.set_var(v, variable, thentype)
#debug "{variable}:{orig or else "?"} isa {mtype or else "?"} -> then {thentype or else "?"}"
end
var elsetype = v.diff_types(self, orig, mtype)
if elsetype != orig then
self.after_flow_context.when_false.set_var(v, variable, elsetype)
#debug "{variable}:{orig or else "?"} isa {mtype or else "?"} -> else {elsetype or else "?"}"
end
end
self.mtype = v.type_bool(self)
end
redef fun accept_post_typing(v)
do
v.check_expr_cast(self, self.n_expr, self.n_type)
end
redef fun dump_info(v) do
var res = super
var mtype = self.cast_type
if mtype != null then
res += v.yellow(".as({mtype})")
end
return res
end
end
src/semantize/typing.nit:1821,1--1870,3
redef class AIsaExpr
redef fun accept_rapid_type_visitor(v)
do
var cast_type = self.cast_type
if cast_type == null then return
v.add_cast_type(cast_type)
end
end
src/rapid_type_analysis.nit:657,1--664,3
redef class AIsaExpr
redef fun accept_explain_assert(v)
do
if n_expr.mtype == null then return
v.explain_expr n_expr
v.explain_string " {n_kwisa.text} "
v.explain_string n_type.collect_text
end
end
src/frontend/explain_assert.nit:233,1--242,3
redef class AIsaExpr
# Identifier of the target class type
var id: Int
# If the Cohen test is used, the position of the target id in vtable
var position: Int
# Indicate the status of the optimization for this node
#
# 0 : the default value
# 1 : this test can be implemented with direct access
# 2 : this test must be implemented with perfect hashing
var status: Int = 0
redef fun expr(v)
do
# TODO : a workaround for now
if not v isa VirtualMachine then return super
var recv = v.expr(self.n_expr)
if recv == null then return null
optimize(v, recv.mtype, self.cast_type.as(not null))
var mtype = v.unanchor_type(self.cast_type.as(not null))
# If this test can be optimized, directly call appropriate subtyping methods
if status == 1 and recv.mtype isa MClassType then
# Direct access
return v.bool_instance(v.inter_is_subtype_sst(id, position, recv.mtype.as(MClassType).mclass.vtable.internal_vtable))
else if status == 2 and recv.mtype isa MClassType then
# Perfect hashing
return v.bool_instance(v.inter_is_subtype_ph(id, recv.vtable.mask, recv.mtype.as(MClassType).mclass.vtable.internal_vtable))
else
# Use the slow path (default)
return v.bool_instance(v.is_subtype(recv.mtype, mtype))
end
end
# Optimize a `AIsaExpr`
# `source` the source type of the expression
# `target` the target type of the subtyping test
private fun optimize(v: VirtualMachine, source: MType, target: MType)
do
# If the source class and target class are not classic classes (non-generics) then return
if not source isa MClassType or not target isa MClassType or target isa MGenericType then
return
end
if not target.mclass.abstract_loaded then return
# If the value is positive, the target class has an invariant position in source's structures
var value = source.mclass.get_position_methods(target.mclass)
if value > 0 then
# `value - 2` is the position of the target identifier in source vtable
position = value - 2
status = 1
else
# We use perfect hashing
status = 2
end
id = target.mclass.vtable.id
end
end
src/vm/vm_optimizations.nit:192,1--255,3