Commit c73bb585 authored by Stefan Marr's avatar Stefan Marr

Changed #to:do: into a primitive

TruffleSOM also intrinsifies this.
Signed-off-by: 's avatarStefan Marr <git@stefan-marr.de>
parent c39cc257
Subproject commit a7875882d4711b98b5deb4669e9455157c3ddbd8
Subproject commit 52f74d08fe98905aa13eead3aa26796eaf339ed1
......@@ -4,6 +4,7 @@ from som.vmobjects.biginteger import BigInteger
from som.vmobjects.integer import integer_value_fits, Integer
from som.vmobjects.double import Double
from som.vmobjects.string import String
from som.vmobjects.block import block_evaluate
import math
......@@ -200,6 +201,24 @@ def _fromString(ivkbl, frame, interpreter):
int_value = int(param.get_embedded_string())
frame.push(interpreter.get_universe().new_integer(int_value))
def _toDo(ivkbl, frame, interpreter):
universe = interpreter.get_universe()
block = frame.pop()
limit = frame.pop()
self = frame.pop() # we do leave it on there
block_method = block.get_method()
context = block.get_context()
for i in range(self.get_embedded_integer(), limit.get_embedded_integer() + 1):
b = universe.new_block(block_method, context)
frame.push(b)
frame.push(universe.new_integer(i))
block_evaluate(b, interpreter, frame)
frame.pop()
frame.push(self)
class IntegerPrimitives(Primitives):
def install_primitives(self):
......@@ -218,4 +237,6 @@ class IntegerPrimitives(Primitives):
self._install_instance_primitive(Primitive("=", self._universe, _equals))
self._install_instance_primitive(Primitive("<", self._universe, _lessThan))
self._install_instance_primitive(Primitive("to:do:", self._universe, _toDo))
self._install_class_primitive(Primitive("fromString:", self._universe, _fromString))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment