author | vranyj1 |
Mon, 09 Apr 2012 09:51:32 +0000 | |
branch | jk_new_structure |
changeset 1459 | 9e24f4337d78 |
parent 1370 | 0708027f69b0 |
child 1478 | 329a15eedd36 |
permissions | -rw-r--r-- |
917 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
917 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
917 | 20 |
" |
21 |
"{ Package: 'stx:libjava' }" |
|
22 |
||
1370 | 23 |
Object subclass:#GroovyEvaluator |
1044
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
24 |
instanceVariableNames:'' |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
25 |
classVariableNames:'WorkspaceBinding' |
917 | 26 |
poolDictionaries:'' |
27 |
category:'Languages-Java-Support' |
|
28 |
! |
|
29 |
||
1370 | 30 |
!GroovyEvaluator class methodsFor:'documentation'! |
917 | 31 |
|
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
917 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
917 | 52 |
|
53 |
" |
|
54 |
! ! |
|
55 |
||
1370 | 56 |
!GroovyEvaluator class methodsFor:'utilities'! |
1204 | 57 |
|
58 |
flushWorkspaceBinding |
|
59 |
||
60 |
WorkspaceBinding := nil |
|
61 |
||
62 |
"Created: / 02-12-2011 / 23:23:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
63 |
! ! |
|
64 |
||
1459 | 65 |
!GroovyEvaluator methodsFor:'* As yet uncategorized *'! |
66 |
||
67 |
currentNamespace: ns |
|
68 |
ns notNil ifTrue:[ |
|
69 |
self error:'Smalltalk namespaces not supported by Groovy' |
|
70 |
]. |
|
71 |
||
72 |
"Created: / 07-04-2012 / 09:26:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
73 |
! ! |
|
74 |
||
1370 | 75 |
!GroovyEvaluator methodsFor:'compiler interface'! |
917 | 76 |
|
971 | 77 |
evaluate:source |
78 |
||
79 |
^self evaluate:source in: nil receiver: nil notifying: nil logged: false ifFail: [self error:'Evaluation failed']. |
|
80 |
||
81 |
"Created: / 02-09-2011 / 10:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 |
! |
|
83 |
||
1033 | 84 |
evaluate: source in: context receiver: receiver notifying: requestor logged: logged ifFail: fail |
85 |
| binding shell result | |
|
918 | 86 |
|
1033 | 87 |
JavaVM booted ifFalse: [ |
959 | 88 |
Java initialize. |
89 |
JavaVM initializeVM. |
|
90 |
]. |
|
1044
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
91 |
(requestor notNil and: [ requestor application isKindOf: WorkspaceApplication ]) ifTrue: [ |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
92 |
WorkspaceBinding isNil ifTrue: [ |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
93 |
WorkspaceBinding := (JavaVM classForName: 'groovy.lang.Binding') new. |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
94 |
]. |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
95 |
binding := WorkspaceBinding |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
96 |
] ifFalse: [ |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
97 |
binding := (Java classForName: 'groovy.lang.Binding') new. |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
98 |
]. |
84b7d94d9eb8
Java Workspace now share same binding (i.e., workspace variables are remembered)
vranyj1
parents:
1033
diff
changeset
|
99 |
|
1033 | 100 |
shell := (Java classForName: 'groovy.lang.GroovyShell') newCleared. |
918 | 101 |
shell perform: #'<init>(Lgroovy/lang/Binding;)V' with: binding. |
102 |
result := shell perform: #'evaluate(Ljava/lang/String;)Ljava/lang/Object;' |
|
1033 | 103 |
with: (Java |
104 |
as_String: (source isText ifTrue: [ source string ] ifFalse: [ source ])). |
|
1202
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
105 |
^ self unbox: result. |
918 | 106 |
|
107 |
"Created: / 17-08-2011 / 08:54:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
108 |
! |
|
109 |
||
917 | 110 |
moreSharedPools: pools |
111 |
||
112 |
"Ignored for Java" |
|
113 |
||
114 |
"Created: / 16-08-2011 / 10:15:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
115 |
! ! |
|
116 |
||
1370 | 117 |
!GroovyEvaluator methodsFor:'private'! |
1202
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
118 |
|
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
119 |
unbox: anObject |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
120 |
|
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
121 |
| nm | |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
122 |
nm := anObject class name. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
123 |
|
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
124 |
nm == #'java/lang/Byte' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
125 |
^anObject instVarNamed: #value. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
126 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
127 |
nm == #'java/lang/Short' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
128 |
^anObject instVarNamed: #value. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
129 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
130 |
nm == #'java/lang/Integer' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
131 |
^anObject instVarNamed: #value. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
132 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
133 |
nm == #'java/lang/Long' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
134 |
^anObject instVarNamed: #value. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
135 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
136 |
nm == #'java/lang/Character' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
137 |
^Character codePoint: (anObject instVarNamed: #value). |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
138 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
139 |
nm == #'java/lang/Boolean' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
140 |
^ (anObject instVarNamed: #value) == 1 |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
141 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
142 |
nm == #'java/lang/String' ifTrue:[ |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
143 |
^ Java as_ST_String: anObject. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
144 |
]. |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
145 |
|
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
146 |
^anObject |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
147 |
|
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
148 |
"Created: / 01-12-2011 / 23:47:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
149 |
! ! |
7d9f24940ed5
- JavaVM: fix in method/ctor invocation using reflection
vranyj1
parents:
1155
diff
changeset
|
150 |
|
1370 | 151 |
!GroovyEvaluator class methodsFor:'documentation'! |
917 | 152 |
|
153 |
version_SVN |
|
154 |
^ '$Id$' |
|
155 |
! ! |