From 6baac631f00d99eef3900357c45baf7a0f0e27dd Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 4 Jan 2016 23:43:49 +0000 Subject: Python backend: Unbox integers by getting ._value directly --- .../org/zwobble/couscous/backends/python/PythonCodeGenerator.java | 3 ++- src/main/resources/python/runtime/_couscous.py | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'src') 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 -- cgit v1.2.3