diff options
Diffstat (limited to 'src/main/java/org/zwobble/couscous/backends/python')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java | 11 |
1 files changed, 8 insertions, 3 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 2320a5a..95f8b9e 100644 --- a/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java +++ b/src/main/java/org/zwobble/couscous/backends/python/PythonCodeGenerator.java @@ -140,7 +140,7 @@ public class PythonCodeGenerator { method.isStatic() ? Collections.<String>emptyList() : asList("self"), explicitArgumentNames); List<PythonStatementNode> pythonBody = generateStatements(method.getBody()); - return pythonFunctionDefinition(method.getName(), ImmutableList.copyOf(argumentNames), new PythonBlock(pythonBody)); + return pythonFunctionDefinition(toName(method.signature()), ImmutableList.copyOf(argumentNames), new PythonBlock(pythonBody)); } private static List<PythonStatementNode> generateStatements(List<StatementNode> statements) { @@ -233,7 +233,7 @@ public class PythonCodeGenerator { PrimitiveMethodGenerator primitiveMethodGenerator = PrimitiveMethods.getPrimitiveMethod(methodCall.getReceiver().getType(), methodCall.getMethodName()).get(); return primitiveMethodGenerator.generate(receiver, arguments); } else { - return pythonCall(pythonAttributeAccess(receiver, methodCall.getMethodName()), arguments); + return pythonCall(pythonAttributeAccess(receiver, toName(methodCall.signature())), arguments); } } @@ -241,7 +241,8 @@ public class PythonCodeGenerator { public PythonExpressionNode visit(StaticMethodCallNode staticMethodCall) { TypeName className = staticMethodCall.getClassName(); PythonVariableReferenceNode classReference = pythonVariableReference(className.getSimpleName()); - PythonAttributeAccessNode methodReference = pythonAttributeAccess(classReference, staticMethodCall.getMethodName()); + PythonAttributeAccessNode methodReference = + pythonAttributeAccess(classReference, toName(staticMethodCall.signature())); List<PythonExpressionNode> arguments = generateExpressions(staticMethodCall.getArguments()); return PrimitiveMethods.getPrimitiveStaticMethod(className, staticMethodCall.getMethodName()) @@ -292,6 +293,10 @@ public class PythonCodeGenerator { } } + public static String toName(MethodSignature signature) { + return signature.getName() + "_" + signature.getArguments().size(); + } + private static boolean isPrimitive(ExpressionNode value) { return PrimitiveMethods.isPrimitive(value.getType()); } |
