From aea822ec6f60123ca583601f621e39ab024d361b Mon Sep 17 00:00:00 2001 From: Iulius Curt Date: Thu, 26 Apr 2012 20:11:07 +0300 Subject: [PATCH] Fix bug of not prepending instance vars with self --- java2python/compiler/visitor.py | 2 +- test/Self0.java | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/Self0.java diff --git a/java2python/compiler/visitor.py b/java2python/compiler/visitor.py index cb97f2c..3b55e31 100644 --- a/java2python/compiler/visitor.py +++ b/java2python/compiler/visitor.py @@ -641,7 +641,7 @@ def nodeOpExpr(self, node, memo): """ Accept and processes an operator expression. """ factory = self.factory.expr self.fs = FS.l + ' ' + node.text + ' ' + FS.r - self.left, self.right = visitors = factory(parent=self), factory() + self.left, self.right = visitors = factory(parent=self), factory(parent=self) self.zipWalk(node.children, visitors, memo) acceptAnd = nodeOpExpr diff --git a/test/Self0.java b/test/Self0.java new file mode 100644 index 0000000..269a96e --- /dev/null +++ b/test/Self0.java @@ -0,0 +1,22 @@ +class Self0 { + private int v1 = 100; + public int v2 = 2; + + public int test0(){ + return v2 + v1; + } + + public boolean test1(){ + return (v1 == v2 || v2 < v1 ); + } + + public static void main(String[] args) { + Self0 s = new Self0(); + System.out.println(s.test0()); + if(s.test1()) + System.out.println("True"); + else + System.out.println("False"); + } + +}