nitc :: AAnnotation
nitc :: AAnnotation :: _n_opar
The opening parenthesis of the argumentsnitc :: AAnnotation :: arg_as_id
Get the single argument ofself
as an identifier.
nitc :: AAnnotation :: arg_as_int
Get the single argument ofself
as an Int
.
nitc :: AAnnotation :: arg_as_string
Get the single argument ofself
as a String
.
nitc :: AAnnotation :: as_relative_paths
Parse all arguments as paths relative to the declaring modulenitc :: AAnnotation :: as_version
Returns a version string (example: "1.5.6b42a7c") from an annotationversion(1, 5, git_revision)
.
nitc :: AAnnotation :: construct_condition
Returns the conditions of annotation parameters. If there are several parameters, the result is anAAndExpr
nitc :: AAnnotation :: defaultinit
nitc :: AAnnotation :: init_aannotation
nitc :: AAnnotation :: n_opar=
The opening parenthesis of the argumentsnitc $ AAnnotation :: SELF
Type of this instance, automatically specialized in every classnitc :: pretty $ AAnnotation :: accept_pretty_printer
Start visit ofself
using a PrettyPrinterVisitor
nitc :: parser_prod $ AAnnotation :: n_annotations=
All the annotations attached directly to the nodenitc :: parser_prod $ AAnnotation :: n_atid=
The name of the annotationnitc :: parser_prod $ AAnnotation :: n_cpar=
The closing parenthesisnitc :: parser_prod $ AAnnotation :: n_kwredef=
Theredef
keyword
nitc :: parser_prod $ AAnnotation :: n_opar=
The opening parenthesis of the argumentsnitc :: parser_prod $ AAnnotation :: n_visibility=
The declared visibilitynitc :: parser_prod $ AAnnotation :: replace_child
Replace a child with an other node in the ASTnitc :: parser_prod $ AAnnotation :: visit_all
Visit all nodes in order.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 :: 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 :: AAnnotation :: _n_opar
The opening parenthesis of the argumentsnitc :: ADefinition :: _n_visibility
The declared visibilitynitc :: ANode :: accept_ast_validation
nitc :: ANode :: accept_auto_super_init
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 :: ANode :: after_simple_misc
nitc :: AAnnotation :: arg_as_id
Get the single argument ofself
as an identifier.
nitc :: AAnnotation :: arg_as_int
Get the single argument ofself
as an Int
.
nitc :: AAnnotation :: arg_as_string
Get the single argument ofself
as a String
.
nitc :: AAnnotation :: as_relative_paths
Parse all arguments as paths relative to the declaring modulenitc :: AAnnotation :: as_version
Returns a version string (example: "1.5.6b42a7c") from an annotationversion(1, 5, git_revision)
.
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 :: AAnnotation :: construct_condition
Returns the conditions of annotation parameters. If there are several parameters, the result is anAAndExpr
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 :: Prod :: defaultinit
nitc :: AAnnotation :: defaultinit
nitc :: ADefinition :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
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 :: 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 :: AAnnotation :: init_aannotation
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 :: 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 :: AAnnotation :: n_opar=
The opening parenthesis of the argumentsnitc :: ADefinition :: n_visibility=
The declared visibilitycore :: 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 :: ANode :: was_inline
Doesself
was written in one line before transformation?
# A single annotation
class AAnnotation
super ADefinition
# The name of the annotation
var n_atid: AAtid is writable, noinit
# The opening parenthesis of the arguments
var n_opar: nullable TOpar = null is writable
# The list of arguments
var n_args = new ANodes[AExpr](self)
# The closing parenthesis
var n_cpar: nullable TCpar = null is writable
# The name of the annotation
fun name: String
do
return n_atid.n_id.text
end
end
src/parser/parser_nodes.nit:3077,1--3098,3
redef class AAnnotation
init init_aannotation (
n_doc: nullable ADoc,
n_kwredef: nullable TKwredef,
n_visibility: nullable AVisibility,
n_atid: nullable AAtid,
n_opar: nullable TOpar,
n_args: Collection[Object], # Should be Collection[AExpr]
n_cpar: nullable TCpar,
n_annotations: nullable AAnnotations
)
do
_n_doc = n_doc
if n_doc != null then n_doc.parent = self
_n_kwredef = n_kwredef
if n_kwredef != null then n_kwredef.parent = self
_n_visibility = n_visibility
if n_visibility != null then n_visibility.parent = self
_n_atid = n_atid.as(not null)
n_atid.parent = self
_n_opar = n_opar
if n_opar != null then n_opar.parent = self
self.n_args.unsafe_add_all(n_args)
_n_cpar = n_cpar
if n_cpar != null then n_cpar.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_doc == old_child then
n_doc = new_child.as(nullable ADoc)
return
end
if _n_kwredef == old_child then
n_kwredef = new_child.as(nullable TKwredef)
return
end
if _n_visibility == old_child then
n_visibility = new_child.as(nullable AVisibility)
return
end
if _n_atid == old_child then
n_atid = new_child.as(AAtid)
return
end
if _n_opar == old_child then
n_opar = new_child.as(nullable TOpar)
return
end
if n_args.replace_child(old_child, new_child) then return
if _n_cpar == old_child then
n_cpar = new_child.as(nullable TCpar)
return
end
if _n_annotations == old_child then
n_annotations = new_child.as(nullable AAnnotations)
return
end
end
redef fun n_doc=(node)
do
_n_doc = node
if node != null then node.parent = self
end
redef fun n_kwredef=(node)
do
_n_kwredef = node
if node != null then node.parent = self
end
redef fun n_visibility=(node)
do
_n_visibility = node
if node != null then node.parent = self
end
redef fun n_atid=(node)
do
_n_atid = node
node.parent = self
end
redef fun n_opar=(node)
do
_n_opar = node
if node != null then node.parent = self
end
redef fun n_cpar=(node)
do
_n_cpar = 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_doc)
v.enter_visit(_n_kwredef)
v.enter_visit(_n_visibility)
v.enter_visit(_n_atid)
v.enter_visit(_n_opar)
n_args.visit_all(v)
v.enter_visit(_n_cpar)
v.enter_visit(_n_annotations)
end
end
src/parser/parser_prod.nit:8698,1--8808,3
redef class AAnnotation
# Get the single argument of `self` as a `String`.
# Raise error and return null on any inconsistency.
fun arg_as_string(modelbuilder: ModelBuilder): nullable String
do
var args = n_args
if args.length == 1 then
var arg = args.first.as_string
if arg != null then return arg
end
modelbuilder.error(self, "Syntax Error: `{name}` expects a single String as argument.")
return null
end
# Get the single argument of `self` as an `Int`.
# Raise error and return null on any inconsistency.
fun arg_as_int(modelbuilder: ModelBuilder): nullable Int
do
var args = n_args
if args.length == 1 then
var arg = args.first.as_int
if arg != null then return arg
end
modelbuilder.error(self, "Syntax Error: `{name}` expects a single Int as argument.")
return null
end
# Get the single argument of `self` as an identifier.
# Raise error and return null on any inconsistency.
fun arg_as_id(modelbuilder: ModelBuilder): nullable String
do
var args = n_args
if args.length == 1 then
var arg = args.first.as_id
if arg != null then return arg
end
modelbuilder.error(self, "Syntax Error: `{name}` expects a single identifier as argument.")
return null
end
end
src/annotation.nit:39,1--81,3
redef class AAnnotation
redef fun accept_pretty_printer(v) do
if n_visibility != null and not n_visibility isa APublicVisibility then
v.visit n_visibility
v.adds
end
v.visit n_atid
v.visit_args n_args
end
end
src/pretty.nit:535,1--544,3
redef class AAnnotation
# Returns a version string (example: "1.5.6b42a7c") from an annotation `version(1, 5, git_revision)`.
#
# The user can enter as many fields as needed. The call to `git_revision` will be replaced by the short
# revision number. If the working tree is dirty, it will append another field with "d" for dirty.
private fun as_version(modelbuilder: ModelBuilder): String
do
var version_fields = new Array[Object]
var args = n_args
if args.length < 1 then
modelbuilder.error(self, "Syntax Error: `{name}` expects at least one argument.")
return ""
else
for arg in args do
var value
value = arg.as_int
if value != null then
version_fields.add value
continue
end
value = arg.as_string
if value != null then
version_fields.add value
end
value = arg.as_id
if value == "git_revision" then
# Get Git short revision
var proc = new ProcessReader("git", "rev-parse", "--short", "HEAD")
proc.wait
if proc.status != 0 then
# Fallback if this is not a git repository or git bins are missing
version_fields.add "0"
modelbuilder.warning(self, "git_revision", "Warning: `git_revision` used outside of a git repository or git binaries not available")
continue
end
var lines = proc.read_all
var revision = lines.split("\n").first
# Is it dirty?
# If not, the return of `git diff --shortstat` is an empty line
proc = new ProcessReader("git", "diff-index", "--quiet", "HEAD")
proc.wait
var dirty = proc.status != 0
if dirty then revision += ".d"
version_fields.add revision
continue
end
var format_error = "Syntax Error: `{name}` expects its arguments to be of type Int or a call to `git_revision`."
modelbuilder.error(self, format_error)
return ""
end
end
return version_fields.join(".")
end
# Parse all arguments as paths relative to the declaring module
#
# If no arguments are given, then use the parent directory of the module.
private fun as_relative_paths(modelbuilder: ModelBuilder): Array[String]
do
var paths = new Array[String]
var file = location.file
if file == null then return paths
var args = n_args
if args.is_empty then
paths.add file.filename.dirname
else
for arg in args do
var val = arg.as_string
if val != null then
paths.add file.filename.dirname/val
else modelbuilder.error(arg, "Syntax Error: `app_files` expects String literals as arguments.")
end
end
return paths
end
end
src/platform/app_annotations.nit:82,1--168,3
redef class AAnnotation
redef fun accept_ast_validation(v)
do
# Do not enter in annotations
end
private init make(n_args : ANodes[AExpr])
do
_n_visibility = new APublicVisibility
_n_args = n_args
end
end
src/astbuilder.nit:935,1--947,3
redef class AAnnotation
# Returns the conditions of annotation parameters. If there are several parameters, the result is an `AAndExpr`
# Example:
# the contract `ensure(true, i == 10, f >= 1.0)`
# return this condition `(true and i == 10 and f >= 1.0)`
private fun construct_condition(v : ContractsVisitor): AExpr
do
var n_condition = n_args.first
n_args.remove_at(0)
for n_arg in n_args do n_condition = v.ast_builder.make_and(n_condition, n_arg)
return n_condition
end
end
src/contracts.nit:289,1--302,3