1368
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
|
|
4 |
New code and modifications done at SWING Research Group [1]:
|
|
5 |
|
|
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 |
|
|
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
|
|
19 |
as of 1.9.2010
|
|
20 |
"
|
|
21 |
"{ Package: 'stx:libjava' }"
|
|
22 |
|
|
23 |
Object subclass:#GroovyCompiler
|
|
24 |
instanceVariableNames:''
|
|
25 |
classVariableNames:'GroovyClassLoader'
|
|
26 |
poolDictionaries:''
|
|
27 |
category:'Languages-Groovy-Compiler'
|
|
28 |
!
|
|
29 |
|
|
30 |
!GroovyCompiler class methodsFor:'documentation'!
|
|
31 |
|
|
32 |
copyright
|
|
33 |
"
|
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
35 |
|
|
36 |
New code and modifications done at SWING Research Group [1]:
|
|
37 |
|
|
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 |
|
|
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
|
|
51 |
as of 1.9.2010
|
|
52 |
|
|
53 |
"
|
|
54 |
! !
|
|
55 |
|
|
56 |
!GroovyCompiler class methodsFor:'initialization'!
|
|
57 |
|
|
58 |
flushGroovyClassLoader
|
|
59 |
|
|
60 |
GroovyClassLoader := nil
|
|
61 |
|
|
62 |
"Created: / 18-02-2012 / 22:25:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
63 |
! !
|
|
64 |
|
|
65 |
!GroovyCompiler class methodsFor:'instance creation'!
|
|
66 |
|
|
67 |
new
|
|
68 |
"return an initialized instance"
|
|
69 |
|
|
70 |
^ self basicNew initialize.
|
|
71 |
! !
|
|
72 |
|
|
73 |
!GroovyCompiler class methodsFor:'compiler interface'!
|
|
74 |
|
|
75 |
compileClass: source
|
|
76 |
"Compiles a new Groovy class given the source code"
|
|
77 |
|
|
78 |
^self new compileClass: source.
|
|
79 |
|
|
80 |
"Created: / 18-02-2012 / 19:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
81 |
! !
|
|
82 |
|
|
83 |
!GroovyCompiler methodsFor:'compiler interface'!
|
|
84 |
|
|
85 |
compileClass: source
|
|
86 |
"Compiles a new Groovy class given the source code"
|
|
87 |
|
|
88 |
| jclass class |
|
|
89 |
|
|
90 |
jclass := GroovyClassLoader
|
|
91 |
perform: #'parseClass(Ljava/lang/String;)Ljava/lang/Class;'
|
|
92 |
with: (Java as_String: source).
|
|
93 |
jclass isNil ifTrue:[ ^ nil ].
|
|
94 |
|
|
95 |
class := JavaVM classForJavaClassObject: jclass.
|
|
96 |
class setSource: source.
|
|
97 |
^class.
|
|
98 |
|
|
99 |
"Created: / 18-02-2012 / 19:12:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
100 |
! !
|
|
101 |
|
|
102 |
!GroovyCompiler methodsFor:'initialization'!
|
|
103 |
|
|
104 |
initialize
|
|
105 |
|
|
106 |
self initializeGroovyClassLoader
|
|
107 |
|
|
108 |
"Modified: / 18-02-2012 / 19:18:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
109 |
!
|
|
110 |
|
|
111 |
initializeGroovyClassLoader
|
|
112 |
| groovy_lang_GroovyClassLoader |
|
|
113 |
|
|
114 |
GroovyClassLoader notNil ifTrue:[ ^ self ].
|
|
115 |
|
|
116 |
groovy_lang_GroovyClassLoader := Java classForName:'groovy.lang.GroovyClassLoader'.
|
|
117 |
GroovyClassLoader := groovy_lang_GroovyClassLoader newCleared.
|
|
118 |
GroovyClassLoader
|
|
119 |
perform: #'<init>(Ljava/lang/ClassLoader;)V'
|
|
120 |
with: JavaVM systemClassLoader.
|
|
121 |
|
|
122 |
"
|
|
123 |
GroovyClassLoader
|
|
124 |
GroovyCompiler basicNew initializeGroovyClassLoader.
|
|
125 |
GroovyClassLoader := nil.
|
|
126 |
"
|
|
127 |
|
|
128 |
"Created: / 18-02-2012 / 19:14:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
129 |
! !
|
|
130 |
|
|
131 |
!GroovyCompiler class methodsFor:'documentation'!
|
|
132 |
|
|
133 |
version_SVN
|
|
134 |
^ '$Id$'
|
|
135 |
! !
|