aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/python
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-31 18:44:13 +0000
committerMichael Williamson <mike@zwobble.org>2015-10-31 18:44:13 +0000
commit971fb3c743df26c408d752f1bc4137e645f455a2 (patch)
tree995caf9c1cfcc0e4d3ce7da683d59e95fb517d42 /src/main/resources/python
parenta5e68ab6528f62c891479f387877118f90dfa2b8 (diff)
Add partial support for boxing integers
Diffstat (limited to 'src/main/resources/python')
-rw-r--r--src/main/resources/python/runtime/_couscous.py8
-rw-r--r--src/main/resources/python/runtime/java/lang/Integer.py8
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main/resources/python/runtime/_couscous.py b/src/main/resources/python/runtime/_couscous.py
index 0183f0b..70d9a97 100644
--- a/src/main/resources/python/runtime/_couscous.py
+++ b/src/main/resources/python/runtime/_couscous.py
@@ -1,5 +1,11 @@
+from .java.lang.Integer import Integer
+
+
def _div_round_to_zero(a, b):
return -(-a // b) if (a < 0) ^ (b < 0) else a // b
def _mod_round_to_zero(a, b):
- return -(-a % b) if (a < 0) ^ (b < 0) else a % b \ No newline at end of file
+ return -(-a % b) if (a < 0) ^ (b < 0) else a % b
+
+def boxInt(value):
+ return Integer(value)
diff --git a/src/main/resources/python/runtime/java/lang/Integer.py b/src/main/resources/python/runtime/java/lang/Integer.py
index 052f799..e16e7bb 100644
--- a/src/main/resources/python/runtime/java/lang/Integer.py
+++ b/src/main/resources/python/runtime/java/lang/Integer.py
@@ -1,3 +1,11 @@
class Integer(object):
+ @staticmethod
def parseInt(value):
return int(value)
+
+ def __init__(self, value):
+ self._value = value
+
+ def equals(self, other):
+ # TODO: test this properly
+ return isinstance(other, Integer) and other._value == self._value