The form of the invocation (name, arguments, etc.) are specific
nitc :: ASendExpr :: defaultinit
nitc :: ASendExpr :: init_asendexpr
nitc :: ASendExpr :: property_name
The name of the propertynitc :: ASendExpr :: property_node
The node identifying the name (id, operator, etc) for messages.nitc :: ASendExpr :: raw_arguments
An array of all arguments (excluding self)nitc :: auto_super_init $ ASendExpr :: accept_auto_super_init
nitc :: rapid_type_analysis $ ASendExpr :: accept_rapid_type_visitor
nitc :: typing $ ASendExpr :: accept_typing
nitc :: typing $ ASendExpr :: bad_expr_message
An additional information message to explain the role of a child expression.nitc :: contracts $ ASendExpr :: check_callsite
nitc :: htmlight $ ASendExpr :: decorate_tag
Add aditionnal information on a child-token and return an additionnal HInfoBox on itnitc :: java_compiler $ ASendExpr :: expr
Try to compile self as an expressionnitc :: naive_interpreter $ ASendExpr :: expr
Evaluate the node as a possible expression.nitc :: abstract_compiler $ ASendExpr :: expr
Try to compile self as an expressionnitc :: ssa $ ASendExpr :: generate_basic_blocks
Generate recursively basic block for this expressionnitc :: pretty $ ASendExpr :: is_inlinable
Isself
printable in one line?
nitc :: parser_prod $ ASendExpr :: 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 :: 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
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
nitc :: ASendExpr :: 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 :: ASendExpr :: init_asendexpr
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 :: ASendExpr :: property_name
The name of the propertynitc :: ASendExpr :: property_node
The node identifying the name (id, operator, etc) for messages.nitc :: ASendExpr :: raw_arguments
An array of all arguments (excluding self)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 :: 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 :: ABraFormExpr
Whatever looks-like a call of the brackets[]
operator.
x[y,z]+=t
x.m(y)=z
. OR just a simple assignment.
x.m(y)+=z
. OR just a simple complex assignment.
nitc :: ACallrefExpr
A reference to a method with a captured receiver. eg.&x.foo
or just &foo
is self is captured.
redef class ASendExpr
init init_asendexpr (
n_expr: nullable AExpr
)
do
_n_expr = n_expr.as(not null)
n_expr.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
end
redef fun n_expr=(node)
do
_n_expr = node
node.parent = self
end
redef fun visit_all(v: Visitor)
do
v.enter_visit(_n_expr)
end
end
src/parser/parser_prod.nit:3618,1--3646,3
redef class ASendExpr
# The property invoked by the send.
var callsite: nullable CallSite
# Is self a safe call (with `x?.foo`)?
# If so and the receiver is null, then the arguments won't be evaluated
# and the call skipped (replaced with null).
var is_safe: Bool = false
redef fun bad_expr_message(child)
do
if child == self.n_expr then
return "to be the receiver of `{self.property_name}`"
end
return null
end
redef fun accept_typing(v)
do
var nrecv = self.n_expr
var recvtype = v.visit_expr(nrecv)
if nrecv isa ASafeExpr then
# Has the receiver the form `x?.foo`?
# For parsing "reasons" the `?` is in the receiver node, not the call node.
is_safe = true
end
var name = self.property_name
var node = self.property_node
if recvtype == null then return # Forward error
var callsite = null
var unsafe_type = v.anchor_to(recvtype)
var mproperty = v.try_get_mproperty_by_name2(node, unsafe_type, name)
if mproperty == null and nrecv isa AImplicitSelfExpr then
# Special fall-back search in `sys` when noting found in the implicit receiver.
var sysclass = v.try_get_mclass(node, "Sys")
if sysclass != null then
var systype = sysclass.mclass_type
mproperty = v.try_get_mproperty_by_name2(node, systype, name)
if mproperty != null then
callsite = v.build_callsite_by_name(node, systype, name, false)
if callsite == null then return # Forward error
# Update information, we are looking at `sys` now, not `self`
nrecv.is_sys = true
nrecv.its_variable = null
nrecv.mtype = systype
recvtype = systype
end
end
end
if callsite == null then
# If still nothing, just exit
callsite = v.build_callsite_by_name(node, recvtype, name, nrecv isa ASelfExpr)
if callsite == null then return
end
self.callsite = callsite
var msignature = callsite.msignature
var args = compute_raw_arguments
if not self isa ACallrefExpr then callsite.check_signature(v, node, args)
if callsite.mproperty.is_init then
var vmpropdef = v.mpropdef
if not (vmpropdef isa MMethodDef and vmpropdef.mproperty.is_init) then
v.error(node, "Error: an `init` can only be called from another `init`.")
end
if vmpropdef isa MMethodDef and vmpropdef.mproperty.is_root_init and not callsite.mproperty.is_root_init then
v.error(node, "Error: `{vmpropdef}` cannot call a factory `{callsite.mproperty}`.")
end
end
var ret = msignature.return_mtype
if ret != null then
if is_safe then
# A safe receiver makes that the call is not executed and returns null
ret = ret.as_nullable
end
self.mtype = ret
else
self.is_typed = true
end
end
# The name of the property
# Each subclass simply provide the correct name.
private fun property_name: String is abstract
# The node identifying the name (id, operator, etc) for messages.
#
# Is `self` by default
private fun property_node: ANode do return self
# An array of all arguments (excluding self)
fun raw_arguments: Array[AExpr] do return compute_raw_arguments
private fun compute_raw_arguments: Array[AExpr] is abstract
redef fun dump_info(v) do
var res = super
var callsite = self.callsite
if callsite != null then
res += v.yellow(" call="+callsite.dump_info(v))
end
return res
end
end
src/semantize/typing.nit:1950,1--2060,3
redef class ASendExpr
redef fun accept_rapid_type_visitor(v)
do
v.add_callsite(callsite)
end
end
src/rapid_type_analysis.nit:700,1--705,3
redef class ASendExpr
redef fun expr(v)
do
var recv = v.expr(self.n_expr)
if recv == null then return null
# Safe call shortcut if recv is null
if is_safe and recv.is_null then
return recv
end
var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
if args == null then return null
var res = v.callsite(callsite, args)
return res
end
end
src/interpreter/naive_interpreter.nit:2278,1--2294,3
redef class ASendExpr
redef fun generate_basic_blocks(ssa, old_block)
do
# A call does not finish the current block,
# because we create intra-procedural basic blocks here
ssa.propdef.object_sites.add(self)
# Recursively goes into arguments to find variables if any
for e in self.raw_arguments do e.generate_basic_blocks(ssa, old_block)
return self.n_expr.generate_basic_blocks(ssa, old_block)
end
end
src/ssa.nit:839,1--852,3
redef class ASendExpr
redef fun expr(v)
do
var recv = v.expr(self.n_expr, null)
if is_safe then
v.add "if ({recv}!=NULL) \{"
end
var callsite = self.callsite.as(not null)
if callsite.is_broken then return null
var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
var res = v.compile_callsite(callsite, args)
if is_safe then
if res != null then
# `callsite.mpropdef` may reference a method whose
# return type is a primitive type in C. If it is
# the case, we must convert the primitive type to
# a `val*` to support nullable assignment.
# Autobox's job is to convert primitive type to
# nullable type, eg from `Int` to `nullable `Int`.
# The target type reside in `self.mtype`.
var original_res = v.autobox(res, self.mtype.as(not null))
# Here we must create a new_var in case the original
# type is not nullable. We can't call `autobox` to
# convert a complex type to its nullable version.
# eg if we have a type `A`, calling autobox like
# `autobox(A, nullable A)` will return `A` since
# `A` and `nullable A` have the same primitive
# type. The nullable qualifier is only used at
# compile time to add appropriate null checks.
res = v.new_var(self.mtype.as(not null))
v.add("{res} = {original_res};")
v.add("\} else \{")
v.add("{res} = NULL;")
end
v.add("\}")
end
return res
end
end
src/compiler/abstract_compiler.nit:4382,1--4421,3