A collection iterated by a for, its automatic variables and its implicit iterator.

Standard for iterate on a single collection. Multiple for can iterate on more than one collection at once.

Introduced properties

private var _coltype: nullable MClassType

nitc :: AForGroup :: _coltype

private var _it: RuntimeVariable

nitc :: AForGroup :: _it

C variable representing the iterator
private var _method_finish: nullable CallSite

nitc :: AForGroup :: _method_finish

private var _method_is_ok: nullable CallSite

nitc :: AForGroup :: _method_is_ok

private var _method_item: nullable CallSite

nitc :: AForGroup :: _method_item

private var _method_iterator: nullable CallSite

nitc :: AForGroup :: _method_iterator

private var _method_key: nullable CallSite

nitc :: AForGroup :: _method_key

private var _method_lt: nullable CallSite

nitc :: AForGroup :: _method_lt

private var _method_next: nullable CallSite

nitc :: AForGroup :: _method_next

private var _n_expr: AExpr

nitc :: AForGroup :: _n_expr

The expression used as the collection to iterate on
private var _n_ids: ANodes[TId]

nitc :: AForGroup :: _n_ids

The list of name of the automatic variables
private var _n_kwin: TKwin

nitc :: AForGroup :: _n_kwin

The in keyword
private var _variables: nullable Array[Variable]

nitc :: AForGroup :: _variables

The automatic variables in order
fun coltype: nullable MClassType

nitc :: AForGroup :: coltype

protected fun coltype=(coltype: nullable MClassType)

nitc :: AForGroup :: coltype=

init init_aforgroup(n_ids: Collection[Object], n_kwin: nullable TKwin, n_expr: nullable AExpr)

nitc :: AForGroup :: init_aforgroup

private fun it: RuntimeVariable

nitc :: AForGroup :: it

C variable representing the iterator
private fun it=(it: RuntimeVariable)

nitc :: AForGroup :: it=

C variable representing the iterator
protected fun method_finish=(method_finish: nullable CallSite)

nitc :: AForGroup :: method_finish=

protected fun method_is_ok=(method_is_ok: nullable CallSite)

nitc :: AForGroup :: method_is_ok=

protected fun method_item=(method_item: nullable CallSite)

nitc :: AForGroup :: method_item=

protected fun method_iterator=(method_iterator: nullable CallSite)

nitc :: AForGroup :: method_iterator=

protected fun method_key=(method_key: nullable CallSite)

nitc :: AForGroup :: method_key=

fun method_lt: nullable CallSite

nitc :: AForGroup :: method_lt

protected fun method_lt=(method_lt: nullable CallSite)

nitc :: AForGroup :: method_lt=

protected fun method_next=(method_next: nullable CallSite)

nitc :: AForGroup :: method_next=

protected fun method_successor=(method_successor: nullable CallSite)

nitc :: AForGroup :: method_successor=

fun n_expr: AExpr

nitc :: AForGroup :: n_expr

The expression used as the collection to iterate on
fun n_expr=(n_expr: AExpr)

nitc :: AForGroup :: n_expr=

The expression used as the collection to iterate on
fun n_ids: ANodes[TId]

nitc :: AForGroup :: n_ids

The list of name of the automatic variables
protected fun n_ids=(n_ids: ANodes[TId])

nitc :: AForGroup :: n_ids=

The list of name of the automatic variables
fun n_kwin: TKwin

nitc :: AForGroup :: n_kwin

The in keyword
fun n_kwin=(n_kwin: TKwin)

nitc :: AForGroup :: n_kwin=

The in keyword
private fun transform_in(v: TransformVisitor, before: AExpr, begin: AExpr, next: AExpr, finish: AExpr, escapemark: EscapeMark)

nitc :: AForGroup :: transform_in

fun variables: nullable Array[Variable]

nitc :: AForGroup :: variables

The automatic variables in order
protected fun variables=(variables: nullable Array[Variable])

nitc :: AForGroup :: variables=

The automatic variables in order

Redefined properties

redef type SELF: AForGroup

nitc $ AForGroup :: SELF

Type of this instance, automatically specialized in every class
redef fun accept_pretty_printer(v: PrettyPrinterVisitor)

nitc :: pretty $ AForGroup :: accept_pretty_printer

Start visit of self using a PrettyPrinterVisitor
redef fun decorate_tag(v: HtmlightVisitor, res: HTMLTag, token: Token): nullable HInfoBox

nitc :: htmlight $ AForGroup :: decorate_tag

Add aditionnal information on a child-token and return an additionnal HInfoBox on it
redef fun n_expr=(node: AExpr)

nitc :: parser_prod $ AForGroup :: n_expr=

The expression used as the collection to iterate on
redef fun n_kwin=(node: TKwin)

nitc :: parser_prod $ AForGroup :: n_kwin=

The in keyword
redef fun replace_child(old_child: ANode, new_child: nullable ANode)

nitc :: parser_prod $ AForGroup :: replace_child

Replace a child with an other node in the AST
redef fun visit_all(v: Visitor)

nitc :: parser_prod $ AForGroup :: visit_all

Visit all nodes in order.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _coltype: nullable MClassType

nitc :: AForGroup :: _coltype

private var _first_location: nullable Location

nitc :: Prod :: _first_location

Location on the first token after the start of a production
private var _first_token: nullable Token

nitc :: Prod :: _first_token

The first token of the production in the AST
private var _force_block: Bool

nitc :: ANode :: _force_block

Force self to be rendered as a block.
private var _force_inline: Bool

nitc :: ANode :: _force_inline

Force self to be rendered as a line.
private var _is_broken: Bool

nitc :: ANode :: _is_broken

The indication that the node did not pass some semantic verifications.
private var _it: RuntimeVariable

nitc :: AForGroup :: _it

C variable representing the iterator
private var _last_token: nullable Token

nitc :: Prod :: _last_token

The last token of the production in the AST
private var _location: Location

nitc :: ANode :: _location

Location is set during AST building. Once built, location can not be null.
private var _method_finish: nullable CallSite

nitc :: AForGroup :: _method_finish

private var _method_is_ok: nullable CallSite

nitc :: AForGroup :: _method_is_ok

private var _method_item: nullable CallSite

nitc :: AForGroup :: _method_item

private var _method_iterator: nullable CallSite

nitc :: AForGroup :: _method_iterator

private var _method_key: nullable CallSite

nitc :: AForGroup :: _method_key

private var _method_lt: nullable CallSite

nitc :: AForGroup :: _method_lt

private var _method_next: nullable CallSite

nitc :: AForGroup :: _method_next

private var _n_annotations: nullable AAnnotations

nitc :: Prod :: _n_annotations

All the annotations attached directly to the node
private var _n_expr: AExpr

nitc :: AForGroup :: _n_expr

The expression used as the collection to iterate on
private var _n_ids: ANodes[TId]

nitc :: AForGroup :: _n_ids

The list of name of the automatic variables
private var _n_kwin: TKwin

nitc :: AForGroup :: _n_kwin

The in keyword
private var _parent: nullable ANode

nitc :: ANode :: _parent

Parent of the node in the AST
private var _variables: nullable Array[Variable]

nitc :: AForGroup :: _variables

The automatic variables in order
fun accept_forward_analysis(v: ForwardAnalysis)

nitc :: ANode :: accept_forward_analysis

Apply the forward analysis v to self.
private abstract fun accept_pretty_printer(v: PrettyPrinterVisitor)

nitc :: ANode :: accept_pretty_printer

Start visit of self using a PrettyPrinterVisitor
fun accept_reaching_defs(v: ReachingDefsAnalysis)

nitc :: ANode :: accept_reaching_defs

Apply a ReachingDefsAnalysis to self.
private fun bad_expr_message(child: AExpr): nullable String

nitc :: ANode :: bad_expr_message

An additional information message to explain the role of a child expression.
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
abstract fun clone: SELF

core :: Cloneable :: clone

Duplicate self
fun collect_annotations_by_name(name: String): Array[AAnnotation]

nitc :: ANode :: collect_annotations_by_name

Do a deep search and return an array of node that are annotated
private fun collect_comments: Array[TComment]

nitc :: Prod :: collect_comments

Collect all TComment contained in the production
private abstract fun collect_length: Int

nitc :: ANode :: collect_length

Collect the length (in Char) of the node.
fun collect_text: String

nitc :: Prod :: collect_text

Join the text of all visited tokens
fun collect_tokens_by_text(text: String): Array[Token]

nitc :: ANode :: collect_tokens_by_text

Do a deep search and return an array of tokens that match a given text
fun coltype: nullable MClassType

nitc :: AForGroup :: coltype

protected fun coltype=(coltype: nullable MClassType)

nitc :: AForGroup :: coltype=

fun common_parent(other: ANode): nullable ANode

nitc :: ANode :: common_parent

The most specific common parent between self and other
fun debug(message: String)

nitc :: ANode :: debug

Display a message for the colored location of the node
protected fun decorate_tag(v: HtmlightVisitor, res: HTMLTag, token: Token): nullable HInfoBox

nitc :: ANode :: decorate_tag

Add aditionnal information on a child-token and return an additionnal HInfoBox on it
fun depth: Int

nitc :: ANode :: depth

Number of nodes between self and the root of the AST
fun detach

nitc :: ANode :: detach

Detach a node from its parent
private fun do_cloneable(v: CloneVisitor)

nitc :: ANode :: do_cloneable

fun dump_info(v: ASTDump): String

nitc :: ANode :: dump_info

Information to display on a node
fun dump_tree(display_structural: nullable Bool, display_line: nullable Bool)

nitc :: ANode :: dump_tree

Write the subtree on stdout.
fun fatal(v: NaiveInterpreter, message: String)

nitc :: ANode :: fatal

Aborts the program with a message
fun first_location: nullable Location

nitc :: Prod :: first_location

Location on the first token after the start of a production
protected fun first_location=(first_location: nullable Location)

nitc :: Prod :: first_location=

Location on the first token after the start of a production
fun first_token: nullable Token

nitc :: Prod :: first_token

The first token of the production in the AST
protected fun first_token=(first_token: nullable Token)

nitc :: Prod :: first_token=

The first token of the production in the AST
private fun force_block: Bool

nitc :: ANode :: force_block

Force self to be rendered as a block.
private fun force_block=(force_block: Bool)

nitc :: ANode :: force_block=

Force self to be rendered as a block.
private fun force_inline: Bool

nitc :: ANode :: force_inline

Force self to be rendered as a line.
private fun force_inline=(force_inline: Bool)

nitc :: ANode :: force_inline=

Force self to be rendered as a line.
fun get_annotations(name: String): Array[AAnnotation]

nitc :: Prod :: get_annotations

Return all its annotations of a given name in the order of their declaration
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun get_single_annotation(name: String, modelbuilder: ModelBuilder): nullable AAnnotation

nitc :: Prod :: get_single_annotation

Try to get its single annotation with a given name
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun hot_location: Location

nitc :: ANode :: hot_location

The location of the important part of the node (identifier or whatever)
fun infobox(v: HtmlightVisitor): nullable HInfoBox

nitc :: ANode :: infobox

Return a optional infobox
init init

core :: Object :: init

init init_aforgroup(n_ids: Collection[Object], n_kwin: nullable TKwin, n_expr: nullable AExpr)

nitc :: AForGroup :: init_aforgroup

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_block: Bool

nitc :: Prod :: is_block

Is the production contained in full block of line?
fun is_broken: Bool

nitc :: ANode :: is_broken

The indication that the node did not pass some semantic verifications.
fun is_broken=(is_broken: Bool)

nitc :: ANode :: is_broken=

The indication that the node did not pass some semantic verifications.
private fun is_inlinable: Bool

nitc :: ANode :: is_inlinable

Is self printable in one line?
private fun is_noserialize: Bool

nitc :: ANode :: is_noserialize

Is this node annotated to not be made serializable?
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
private fun is_serialize: Bool

nitc :: ANode :: is_serialize

Is this node annotated to be made serializable?
fun is_span: Bool

nitc :: Prod :: is_span

Is the production a part of a single line (without being a block)
fun is_structural: Bool

nitc :: ANode :: is_structural

Is self a token or a pure-structural production like AQId?
private fun it: RuntimeVariable

nitc :: AForGroup :: it

C variable representing the iterator
private fun it=(it: RuntimeVariable)

nitc :: AForGroup :: it=

C variable representing the iterator
fun last_token: nullable Token

nitc :: Prod :: last_token

The last token of the production in the AST
protected fun last_token=(last_token: nullable Token)

nitc :: Prod :: last_token=

The last token of the production in the AST
fun location: Location

nitc :: ANode :: location

Location is set during AST building. Once built, location can not be null.
fun location=(location: Location)

nitc :: ANode :: location=

Location is set during AST building. Once built, location can not be null.
protected fun make_tag(v: HtmlightVisitor): nullable HTMLTag

nitc :: ANode :: make_tag

Optionally creates a tag that encapsulate the AST element on HTML rendering
protected fun method_finish=(method_finish: nullable CallSite)

nitc :: AForGroup :: method_finish=

protected fun method_is_ok=(method_is_ok: nullable CallSite)

nitc :: AForGroup :: method_is_ok=

protected fun method_item=(method_item: nullable CallSite)

nitc :: AForGroup :: method_item=

protected fun method_iterator=(method_iterator: nullable CallSite)

nitc :: AForGroup :: method_iterator=

protected fun method_key=(method_key: nullable CallSite)

nitc :: AForGroup :: method_key=

fun method_lt: nullable CallSite

nitc :: AForGroup :: method_lt

protected fun method_lt=(method_lt: nullable CallSite)

nitc :: AForGroup :: method_lt=

protected fun method_next=(method_next: nullable CallSite)

nitc :: AForGroup :: method_next=

protected fun method_successor=(method_successor: nullable CallSite)

nitc :: AForGroup :: method_successor=

private fun must_be_block: Bool

nitc :: ANode :: must_be_block

Does self have to be rendered as a block?
private fun must_be_inline: Bool

nitc :: ANode :: must_be_inline

Does self have be rendered as a line?
fun n_annotations: nullable AAnnotations

nitc :: Prod :: n_annotations

All the annotations attached directly to the node
fun n_annotations=(n_annotations: nullable AAnnotations)

nitc :: Prod :: n_annotations=

All the annotations attached directly to the node
fun n_expr: AExpr

nitc :: AForGroup :: n_expr

The expression used as the collection to iterate on
fun n_expr=(n_expr: AExpr)

nitc :: AForGroup :: n_expr=

The expression used as the collection to iterate on
fun n_ids: ANodes[TId]

nitc :: AForGroup :: n_ids

The list of name of the automatic variables
protected fun n_ids=(n_ids: ANodes[TId])

nitc :: AForGroup :: n_ids=

The list of name of the automatic variables
fun n_kwin: TKwin

nitc :: AForGroup :: n_kwin

The in keyword
fun n_kwin=(n_kwin: TKwin)

nitc :: AForGroup :: n_kwin=

The in keyword
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun parent: nullable ANode

nitc :: ANode :: parent

Parent of the node in the AST
protected fun parent=(parent: nullable ANode)

nitc :: ANode :: parent=

Parent of the node in the AST
fun parentize_tokens

nitc :: ANode :: parentize_tokens

Visit the AST and computes advanced AST attributes on Tokens and Prod
private abstract fun replace_child(old_child: ANode, new_child: nullable ANode)

nitc :: ANode :: replace_child

Replace a child with an other node in the AST
fun replace_clone

nitc :: ANode :: replace_clone

Create a new clone of self
fun replace_with(node: ANode)

nitc :: ANode :: replace_with

Replace itself with an other node in the AST
fun root: ANode

nitc :: ANode :: root

The topmost ancestor of the element
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
private fun start_token: nullable Token

nitc :: Prod :: start_token

The token where the production really start (skipping ADoc).
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun to_xml: HTMLTag

nitc :: Prod :: to_xml

A XML representation of the AST
private fun transform_in(v: TransformVisitor, before: AExpr, begin: AExpr, next: AExpr, finish: AExpr, escapemark: EscapeMark)

nitc :: AForGroup :: transform_in

fun validate

nitc :: ANode :: validate

Recursively validate a AST node.
fun variables: nullable Array[Variable]

nitc :: AForGroup :: variables

The automatic variables in order
protected fun variables=(variables: nullable Array[Variable])

nitc :: AForGroup :: variables=

The automatic variables in order
abstract fun visit_all(v: Visitor)

nitc :: ANode :: visit_all

Visit all nodes in order.
private abstract fun was_inline: Bool

nitc :: ANode :: was_inline

Does self was written in one line before transformation?
package_diagram nitc::AForGroup AForGroup nitc::Prod Prod nitc::AForGroup->nitc::Prod nitc::ANode ANode nitc::Prod->nitc::ANode ...nitc::ANode ... ...nitc::ANode->nitc::ANode

Ancestors

abstract class ANode

nitc :: ANode

Root of the AST class-hierarchy
interface Cloneable

core :: Cloneable

Something that can be cloned
interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class Prod

nitc :: Prod

Ancestor of all productions

Class definitions

nitc $ AForGroup
# A collection iterated by a for, its automatic variables and its implicit iterator.
#
# Standard `for` iterate on a single collection.
# Multiple `for` can iterate on more than one collection at once.
class AForGroup
	super Prod

	# The list of name of the automatic variables
	var n_ids = new ANodes[TId](self)

	# The `in` keyword
	var n_kwin: TKwin is writable, noinit

	# The expression used as the collection to iterate on
	var n_expr: AExpr is writable, noinit
end
src/parser/parser_nodes.nit:2051,1--2066,3

nitc :: parser_prod $ AForGroup
redef class AForGroup
	init init_aforgroup (
		n_ids: Collection[Object], # Should be Collection[TId]
		n_kwin: nullable TKwin,
		n_expr: nullable AExpr
	)
	do
		self.n_ids.unsafe_add_all(n_ids)
		_n_kwin = n_kwin.as(not null)
		n_kwin.parent = self
		_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_ids.replace_child(old_child, new_child) then return
		if _n_kwin == old_child then
			n_kwin = new_child.as(TKwin)
			return
		end
		if _n_expr == old_child then
			n_expr = new_child.as(AExpr)
			return
		end
	end

	redef fun n_kwin=(node)
	do
		_n_kwin = node
		node.parent = self
	end
	redef fun n_expr=(node)
	do
		_n_expr = node
		node.parent = self
	end


	redef fun visit_all(v: Visitor)
	do
		n_ids.visit_all(v)
		v.enter_visit(_n_kwin)
		v.enter_visit(_n_expr)
	end
end
src/parser/parser_prod.nit:8003,1--8048,3

nitc :: simple_misc_analysis $ AForGroup
redef class AForGroup
	redef fun after_simple_misc(v)
	do
		n_expr.warn_parentheses(v)
	end
end
src/frontend/simple_misc_analysis.nit:179,1--184,3

nitc :: scope $ AForGroup
redef class AForGroup
	# The automatic variables in order
	var variables: nullable Array[Variable]
end
src/semantize/scope.nit:446,1--449,3

nitc :: pretty $ AForGroup
redef class AForGroup
	redef fun accept_pretty_printer(v) do
		for n_id in n_ids do
			v.visit n_id
			if n_id != n_ids.last then v.add ", "
		end

		v.adds
		v.consume "in"
		v.adds
		v.visit n_expr
	end
end
src/pretty.nit:1534,1--1546,3

nitc :: typing $ AForGroup
redef class AForGroup
	var coltype: nullable MClassType

	var method_iterator: nullable CallSite
	var method_is_ok: nullable CallSite
	var method_item: nullable CallSite
	var method_next: nullable CallSite
	var method_key: nullable CallSite
	var method_finish: nullable CallSite

	var method_lt: nullable CallSite
	var method_successor: nullable CallSite

	private fun do_type_iterator(v: TypeVisitor, mtype: MType)
	do
		if mtype isa MNullType then
			v.error(self, "Type Error: `for` cannot iterate over `null`.")
			return
		end

		# get obj class
		var objcla = v.get_mclass(self, "Object")
		if objcla == null then return

		# check iterator method
		var itdef = v.build_callsite_by_name(self, mtype, "iterator", n_expr isa ASelfExpr)
		if itdef == null then
			v.error(self, "Type Error: `for` expects a type providing an `iterator` method, got `{mtype}`.")
			return
		end
		self.method_iterator = itdef

		# check that iterator return something
		var ittype = itdef.msignature.return_mtype
		if ittype == null then
			v.error(self, "Type Error: `for` expects the method `iterator` to return an `Iterator` or `MapIterator` type.")
			return
		end

		# get iterator type
		var colit_cla = v.try_get_mclass(self, "Iterator")
		var mapit_cla = v.try_get_mclass(self, "MapIterator")
		var is_col = false
		var is_map = false

		if colit_cla != null and v.is_subtype(ittype, colit_cla.get_mtype([objcla.mclass_type.as_nullable])) then
			# Iterator
			var coltype = ittype.supertype_to(v.mmodule, v.anchor, colit_cla)
			var variables =  self.variables
			if variables.length != 1 then
				v.error(self, "Type Error: `for` expects only one variable when using `Iterator`.")
			else
				variables.first.declared_type = coltype.arguments.first
			end
			is_col = true
		end

		if mapit_cla != null and v.is_subtype(ittype, mapit_cla.get_mtype([objcla.mclass_type.as_nullable, objcla.mclass_type.as_nullable])) then
			# Map Iterator
			var coltype = ittype.supertype_to(v.mmodule, v.anchor, mapit_cla)
			var variables = self.variables
			if variables.length != 2 then
				v.error(self, "Type Error: `for` expects two variables when using `MapIterator`.")
			else
				variables[0].declared_type = coltype.arguments[0]
				variables[1].declared_type = coltype.arguments[1]
			end
			is_map = true
		end

		if not is_col and not is_map then
			v.error(self, "Type Error: `for` expects the method `iterator` to return an `Iterator` or `MapIterator` type.")
			return
		end

		# anchor formal and virtual types
		if mtype.need_anchor then mtype = v.anchor_to(mtype)

		mtype = mtype.undecorate
		self.coltype = mtype.as(MClassType)

		# get methods is_ok, next, item
		var ikdef = v.build_callsite_by_name(self, ittype, "is_ok", false)
		if ikdef == null then
			v.error(self, "Type Error: `for` expects a method `is_ok` in type `{ittype}`.")
			return
		end
		self.method_is_ok = ikdef

		var itemdef = v.build_callsite_by_name(self, ittype, "item", false)
		if itemdef == null then
			v.error(self, "Type Error: `for` expects a method `item` in type `{ittype}`.")
			return
		end
		self.method_item = itemdef

		var nextdef = v.build_callsite_by_name(self, ittype, "next", false)
		if nextdef == null then
			v.error(self, "Type Error: `for` expects a method `next` in type {ittype}.")
			return
		end
		self.method_next = nextdef

		self.method_finish = v.try_build_callsite_by_name(self, ittype, "finish", false)

		if is_map then
			var keydef = v.build_callsite_by_name(self, ittype, "key", false)
			if keydef == null then
				v.error(self, "Type Error: `for` expects a method `key` in type `{ittype}`.")
				return
			end
			self.method_key = keydef
		end

		if self.variables.length == 1 and n_expr isa ARangeExpr then
			var variable = variables.first
			var vtype = variable.declared_type.as(not null)

			if n_expr isa AOrangeExpr then
				self.method_lt = v.build_callsite_by_name(self, vtype, "<", false)
			else
				self.method_lt = v.build_callsite_by_name(self, vtype, "<=", false)
			end

			self.method_successor = v.build_callsite_by_name(self, vtype, "successor", false)
		end
	end
end
src/semantize/typing.nit:1345,1--1472,3

nitc :: abstract_compiler $ AForGroup
redef class AForGroup
	# C variable representing the iterator
	private var it: RuntimeVariable is noinit
end
src/compiler/abstract_compiler.nit:3988,1--3991,3

nitc :: transform $ AForGroup
redef class AForGroup
	private fun transform_in(v: TransformVisitor, before, begin, next, finish: AExpr, escapemark: EscapeMark)
	do
		var nexpr = n_expr

		# Shortcut on explicit range
		# Avoid the instantiation of the range and the iterator
		if self.variables.length == 1 and nexpr isa ARangeExpr and not v.phase.toolcontext.opt_no_shortcut_range.value then
			# Before: evaluate bounds
			var variable = variables.first
			before.add v.builder.make_var_assign(variable, nexpr.n_expr)
			var to = nexpr.n_expr2
			before.add to

			# Begin: check variable
			var is_ok = v.builder.make_call(v.builder.make_var_read(variable, variable.declared_type.as(not null)), method_lt.as(not null), [to.make_var_read])
			var nif = v.builder.make_if(is_ok, null)
			begin.add nif
			nif.n_else.add v.builder.make_break(escapemark)

			# Next: increment one
			var one = v.builder.make_int(1)
			var succ = v.builder.make_call(v.builder.make_var_read(variable, variable.declared_type.as(not null)), method_successor.as(not null), [one])
			next.add v.builder.make_var_assign(variable, succ)
			return
		end

		# Before: evaluate expr, make the iterator
		before.add nexpr
		var iter = v.builder.make_call(nexpr.make_var_read, method_iterator.as(not null), null)
		before.add iter

		# Begin: check iterator `is_ok`
		var is_ok = v.builder.make_call(iter.make_var_read, method_is_ok.as(not null), null)
		var nif = v.builder.make_if(is_ok, null)
		begin.add nif
		nif.n_else.add v.builder.make_break(escapemark)

		# Begin: assign automatic variables
		if variables.length == 1 then
			var item = v.builder.make_call(iter.make_var_read, method_item.as(not null), null)
			begin.add v.builder.make_var_assign(variables.first, item)
		else if variables.length == 2 then
			var key = v.builder.make_call(iter.make_var_read, method_key.as(not null), null)
			begin.add v.builder.make_var_assign(variables[0], key)
			var item = v.builder.make_call(iter.make_var_read, method_item.as(not null), null)
			begin.add v.builder.make_var_assign(variables[1], item)
		else
			abort
		end

		# Next: call next
		next.add v.builder.make_call(iter.make_var_read, method_next.as(not null), null)

		# Finish: call finish
		var method_finish = method_finish
		if method_finish != null then
			finish.add v.builder.make_call(iter.make_var_read, method_finish, null)
		end
	end
end
src/transform.nit:248,1--308,3

nitc :: htmlight $ AForGroup
redef class AForGroup
	redef fun decorate_tag(v, res, token)
	do
		if not token isa TId then return null
		var vs = variables
		if vs == null then return null
		res.add_class("nc_v")
		var idx = n_ids.index_of(token)
		var variable = vs[idx]
		return variable.infobox(v)
	end
end
src/htmlight.nit:857,1--868,3