Give a position to each variable declared in the node.

NOTE: Do not call this method directly, but use v.numbering This method is here to be implemented by subclasses. v The current instance of the virtual machine position The first available position in the environment a variable can have Return the next available position a variable can have

Property definitions

nitc :: variables_numbering $ AExpr :: numbering
	# Give a position to each variable declared in the node.
	# NOTE: Do not call this method directly, but use `v.numbering`
	# This method is here to be implemented by subclasses.
	# *`v` The current instance of the virtual machine
	# *`position` The first available position in the environment a variable can have
	# Return the next available position a variable can have
	public fun numbering(v: VirtualMachine, position: Int): Int
	do
		return position
	end
src/vm/variables_numbering.nit:83,2--92,4

nitc :: variables_numbering $ ABlockExpr :: numbering
	redef fun numbering(v, position)
	do
		for e in self.n_expr do
			position = v.numbering(e, position)
		end
		return position
	end
src/vm/variables_numbering.nit:194,2--200,4

nitc :: variables_numbering $ AVardeclExpr :: numbering
	redef fun numbering(v, position)
	do
		# Attribute a position to this variable
		self.variable.as(not null).position = position
		position += 1

		# Recursively continue to numbering the variables
		position = v.numbering(self.n_expr, position)

		# `position` is the next available position in the environment
		return position
	end
src/vm/variables_numbering.nit:179,2--190,4

nitc :: variables_numbering $ AIfExpr :: numbering
	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
src/vm/variables_numbering.nit:204,2--215,4

nitc :: variables_numbering $ AIfexprExpr :: numbering
	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
src/vm/variables_numbering.nit:219,2--230,4

nitc :: variables_numbering $ AArrayExpr :: numbering
	redef fun numbering(v, position)
	do
		for nexpr in self.n_exprs do
			position = v.numbering(nexpr, position)
		end
		return position
	end
src/vm/variables_numbering.nit:276,2--282,4

nitc :: variables_numbering $ ADoExpr :: numbering
	redef fun numbering(v, position)
	do
		return v.numbering(self.n_block, position)
	end
src/vm/variables_numbering.nit:234,2--237,4

nitc :: variables_numbering $ AWhileExpr :: numbering
	redef fun numbering(v, position)
	do
		return v.numbering(self.n_block, position)
	end
src/vm/variables_numbering.nit:241,2--244,4

nitc :: variables_numbering $ ALoopExpr :: numbering
	redef fun numbering(v, position)
	do
		return v.numbering(self.n_block, position)
	end
src/vm/variables_numbering.nit:248,2--251,4

nitc :: variables_numbering $ AForExpr :: numbering
	redef fun numbering(v, position)
	do
		for g in n_groups do
			# Give a position to each variable declared in the header of the for
			if g.variables.length == 1 then
				g.variables.first.position = position
				g.variables[0].position = position
				position += 1
			else if g.variables.length == 2 then
				g.variables[0].position = position
				position += 1
				g.variables[1].position = position
				position += 1
			end
			position = v.numbering(self.n_block, position)
		end
		return position
	end
src/vm/variables_numbering.nit:255,2--272,4