2004-11-15 | Paul Boddie | file changeset files shortlog | Replaced apply usage with CALL_FUNCTION_VAR. Changed *static instruction translations to use the class name rather than self.__class__ although this is likely to be insufficient. Added static field definition and support for the <clinit> method as a class method in Python classes. Changed superclass loading to hopefully get sibling classes directly from the global namespace. Adopted globals() in the bytecode test program for the global namespace. Fixed classhook to avoid "restricted mode" issues with the global namespace used, added calling of __clinit__ (the Python equivalent of <clinit>), and introduced improved processing of classes by ordering them according to superclass dependencies. |
paul@16 | 1 | public class Value { |
paul@28 | 2 | protected int value; |
paul@16 | 3 | |
paul@16 | 4 | public Value(int value) { |
paul@16 | 5 | this.value = value; |
paul@16 | 6 | } |
paul@16 | 7 | |
paul@16 | 8 | public int getValue() { |
paul@16 | 9 | return this.value; |
paul@16 | 10 | } |
paul@16 | 11 | |
paul@16 | 12 | public void setValue(int value) { |
paul@16 | 13 | this.value = value; |
paul@16 | 14 | } |
paul@17 | 15 | |
paul@17 | 16 | public boolean isPositive() { |
paul@17 | 17 | return this.value > 0; |
paul@17 | 18 | } |
paul@17 | 19 | |
paul@17 | 20 | public int compare(int value) { |
paul@17 | 21 | if (value < this.value) { |
paul@17 | 22 | return -1; |
paul@17 | 23 | } else if (value == this.value) { |
paul@17 | 24 | return 0; |
paul@17 | 25 | } else { |
paul@17 | 26 | return 1; |
paul@17 | 27 | } |
paul@17 | 28 | } |
paul@17 | 29 | |
paul@17 | 30 | public int add(int value) { |
paul@17 | 31 | return this.value + value; |
paul@17 | 32 | } |
paul@20 | 33 | |
paul@20 | 34 | public Value newValue() { |
paul@20 | 35 | return new Value(this.getValue()); |
paul@20 | 36 | } |
paul@16 | 37 | } |
paul@16 | 38 | |
paul@16 | 39 | // vim: tabstop=4 expandtab shiftwidth=4 |