aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-01-04 23:43:49 +0000
committerMichael Williamson <mike@zwobble.org>2016-01-04 23:43:49 +0000
commit6baac631f00d99eef3900357c45baf7a0f0e27dd (patch)
treef20c10084acead59100fa21a0a73e5bf33aef540
parent81cab75d3b50e47ee6db414c38d5f31b95fc5b06 (diff)
Python backend: Unbox integers by getting ._value directly
-rw-r--r--src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java3
-rw-r--r--src/main/resources/python/runtime/_couscous.py8
2 files changed, 3 insertions, 8 deletions
diff --git a/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java b/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java
index 47b007b..2320a5a 100644
--- a/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java
+++ b/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java
@@ -266,9 +266,10 @@ public class PythonCodeGenerator {
public PythonExpressionNode visit(TypeCoercionNode typeCoercion) {
PythonExpressionNode value = generateExpression(typeCoercion.getExpression());
if (isIntegerBox(typeCoercion)) {
+ // TODO: replace with direct access to java.lang.Integer
return internalMethod("boxInt", asList(value));
} else if (isIntegerUnbox(typeCoercion)) {
- return internalMethod("unboxInt", asList(value));
+ return pythonAttributeAccess(value, "_value");
} else {
return value;
}
diff --git a/src/main/resources/python/runtime/_couscous.py b/src/main/resources/python/runtime/_couscous.py
index 8d92f8e..b8ab6fd 100644
--- a/src/main/resources/python/runtime/_couscous.py
+++ b/src/main/resources/python/runtime/_couscous.py
@@ -9,10 +9,4 @@ def _mod_round_to_zero(a, b):
return -(-a % b) if (a < 0) ^ (b < 0) else a % b
def boxInt(value):
- return Integer(value)
-
-def unboxInt(value):
- return value._value
-
-def boxBoolean(value):
- return Boolean(value) \ No newline at end of file
+ return Integer(value) \ No newline at end of file