Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Execute.java @ 22108:f84a7663966d
Adding Message.createNew into standard interop messages so languages like Ruby and Java can use 'new' to instantiate Java classes.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 26 Aug 2015 12:51:55 +0200 |
parents | 9c8c0937da41 |
children | e70b20f4bb00 |
comparison
equal
deleted
inserted
replaced
22107:29126a670f9b | 22108:f84a7663966d |
---|---|
23 * questions. | 23 * questions. |
24 */ | 24 */ |
25 package com.oracle.truffle.api.interop; | 25 package com.oracle.truffle.api.interop; |
26 | 26 |
27 final class Execute extends KnownMessage { | 27 final class Execute extends KnownMessage { |
28 public static final int HASH1 = 423430; | 28 public static final int EXECUTE = 423430; |
29 public static final int HASH2 = 423429; | 29 public static final int INVOKE = 423429; |
30 public static final int NEW = 423428; | |
30 | 31 |
31 private final int arity; | 32 private final int arity; |
32 private final boolean invoke; | 33 private final int type; |
33 | 34 |
34 public static Execute create(boolean invoke, int arity) { | 35 public static Execute create(int type, int arity) { |
35 return new Execute(invoke, arity); | 36 return new Execute(type, arity); |
36 } | 37 } |
37 | 38 |
38 private Execute(boolean invoke, int arity) { | 39 private Execute(int type, int arity) { |
39 this.invoke = invoke; | 40 this.type = type; |
40 this.arity = arity; | 41 this.arity = arity; |
41 } | 42 } |
42 | 43 |
43 public int getArity() { | 44 public int getArity() { |
44 return arity; | 45 return arity; |
49 if (!(message instanceof Execute)) { | 50 if (!(message instanceof Execute)) { |
50 return false; | 51 return false; |
51 } | 52 } |
52 Execute m1 = this; | 53 Execute m1 = this; |
53 Execute m2 = (Execute) message; | 54 Execute m2 = (Execute) message; |
54 return m1.invoke == m2.invoke; | 55 return m1.type == m2.type; |
55 } | 56 } |
56 | 57 |
57 @Override | 58 @Override |
58 public int hashCode() { | 59 public int hashCode() { |
59 return invoke ? HASH1 : HASH2; | 60 return type; |
60 } | 61 } |
61 | 62 |
62 @Override | 63 @Override |
63 public String toString() { | 64 public String toString() { |
64 return invoke ? "msgInvoke" : "msgExecute"; | 65 switch (type) { |
66 case EXECUTE: | |
67 return "msgExecute"; | |
68 case INVOKE: | |
69 return "msgInvoke"; | |
70 default: | |
71 return "msgNew"; | |
72 } | |
65 } | 73 } |
66 | |
67 } | 74 } |