author | Stefan Vogel <sv@exept.de> |
Wed, 15 Apr 2020 20:18:14 +0200 | |
changeset 25357 | cec6ca6e3af4 |
parent 25164 | 155994a16fb9 |
permissions | -rw-r--r-- |
21295 | 1 |
" |
21371 | 2 |
COPYRIGHT (c) 2009 by Jan Vrany |
21295 | 3 |
COPYRIGHT (c) 2009 by eXept Software AG |
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
11965 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
17449 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
11965 | 17 |
ProgrammingLanguage subclass:#SmalltalkLanguage |
18 |
instanceVariableNames:'' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Kernel-Languages' |
|
22 |
! |
|
23 |
||
12100 | 24 |
!SmalltalkLanguage class methodsFor:'documentation'! |
25 |
||
21295 | 26 |
copyright |
27 |
" |
|
21371 | 28 |
COPYRIGHT (c) 2009 by Jan Vrany |
21295 | 29 |
COPYRIGHT (c) 2009 by eXept Software AG |
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
12100 | 41 |
documentation |
42 |
" |
|
43 |
provide info about which tools are to be used for smalltalk code |
|
44 |
" |
|
45 |
! ! |
|
11965 | 46 |
|
47 |
!SmalltalkLanguage methodsFor:'accessing'! |
|
48 |
||
22668 | 49 |
id |
50 |
"Return a unique integer id of this language. |
|
22678 | 51 |
For languages built into the VM, it must be < 32. |
52 |
This id is used as index to various structures used by runtime |
|
53 |
(bytecode set ?). |
|
54 |
cg: this ought to be better documented - I have no idea, where it is used" |
|
22668 | 55 |
|
56 |
^ 1 |
|
57 |
||
58 |
"Created: / 12-04-2018 / 09:16:27 / stefan" |
|
59 |
! |
|
60 |
||
11965 | 61 |
name |
12098 | 62 |
"Answers a human-readable name of myself: |
63 |
'Smalltalk' for SmalltalkLanguage, |
|
64 |
'Ruby' for RubyLanguage |
|
65 |
..." |
|
11965 | 66 |
|
12502 | 67 |
^ 'Smalltalk' |
11965 | 68 |
|
69 |
"Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
70 |
! |
|
71 |
||
72 |
sourceFileSuffix |
|
24373 | 73 |
"Answers a default suffix for source files, i.e. |
74 |
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby', etc." |
|
11965 | 75 |
|
76 |
^'st' |
|
77 |
||
78 |
"Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
24373 | 79 |
"Modified (comment): / 27-06-2019 / 12:33:29 / Claus Gittinger" |
11965 | 80 |
! ! |
81 |
||
17449 | 82 |
!SmalltalkLanguage methodsFor:'accessing-classes'! |
11965 | 83 |
|
13259 | 84 |
codeGeneratorClass |
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
85 |
"Answers a class that can generate code" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
86 |
|
13253
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
87 |
^ SmalltalkCodeGeneratorTool |
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
88 |
|
13259 | 89 |
"Created: / 30-01-2011 / 15:19:52 / cg" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
90 |
! |
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
91 |
|
11965 | 92 |
compilerClass |
12098 | 93 |
"Answer a class suitable for compiling a source code in 'my' language" |
11965 | 94 |
|
18874 | 95 |
^ Smalltalk at:#Compiler |
11965 | 96 |
|
97 |
"Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
98 |
! |
|
99 |
||
15538 | 100 |
compilerWithBreakpointSupportClass |
101 |
"Answer a class suitable for compiling a source code with breakpoints |
|
102 |
in 'my' language" |
|
103 |
||
18874 | 104 |
^ ByteCodeCompilerWithBreakpointSupport |
15538 | 105 |
|
106 |
"Created: / 22-07-2013 / 15:46:12 / cg" |
|
107 |
! |
|
108 |
||
11965 | 109 |
explainerClass |
12098 | 110 |
"Answers a class used by browser and debugger to |
111 |
show some hints about the code. It is OK to return |
|
112 |
nil, which means that there is no explainer for given language." |
|
11965 | 113 |
|
114 |
"return nil by default" |
|
18874 | 115 |
^ Explainer |
11965 | 116 |
|
117 |
"Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
118 |
! |
|
119 |
||
12098 | 120 |
formatterClass |
121 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
122 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
123 |
||
18874 | 124 |
^ Parser |
12098 | 125 |
! |
126 |
||
11965 | 127 |
parserClass |
19985 | 128 |
"Answer a class suitable for parsing a source code in 'my' language" |
11965 | 129 |
|
18874 | 130 |
^ Parser |
11965 | 131 |
|
132 |
"Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
133 |
! |
|
134 |
||
135 |
sourceFileReaderClass |
|
12098 | 136 |
"Answers a class that can be used for reading & compiling source files" |
11965 | 137 |
|
138 |
^SmalltalkChunkFileSourceReader |
|
139 |
||
140 |
"Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
141 |
! |
|
142 |
||
143 |
sourceFileWriterClass |
|
12098 | 144 |
"Answers a class is used for source file writing (i.e. file-out)" |
11965 | 145 |
|
12107 | 146 |
^ SmalltalkChunkFileSourceWriter |
11965 | 147 |
|
148 |
"Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12098 | 149 |
! |
150 |
||
151 |
syntaxHighlighterClass |
|
152 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
153 |
this can be redefined in special classes, to highlight classes with |
|
154 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
155 |
||
18874 | 156 |
^ SyntaxHighlighter |
11965 | 157 |
! ! |
158 |
||
159 |
!SmalltalkLanguage methodsFor:'mimicry'! |
|
160 |
||
161 |
, anObject |
|
12098 | 162 |
"Emulates symbol behavior. This is sometimes required |
14069 | 163 |
as 'Smalltalk language' is used by legacy code to access |
164 |
the current language setting. |
|
165 |
Future versions should contain class Locale. |
|
18925 | 166 |
cg: this is crab, who needs this? |
11965 | 167 |
" |
12524 | 168 |
<resource: #obsolete> |
11965 | 169 |
|
15898 | 170 |
self obsoleteMethodWarning. |
18925 | 171 |
^ Smalltalk language , anObject |
11965 | 172 |
|
173 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 174 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 175 |
! |
176 |
||
177 |
asSymbol |
|
12098 | 178 |
"Returns a language symbol. This is sometimes required |
179 |
as Smalltalk language is used by legacy code to access |
|
180 |
current language. Future versions should contain class |
|
181 |
Locale. |
|
18925 | 182 |
cg: this is crab, who needs this? |
11965 | 183 |
" |
12524 | 184 |
<resource: #obsolete> |
11965 | 185 |
|
15898 | 186 |
self obsoleteMethodWarning. |
18925 | 187 |
^ Smalltalk language |
11965 | 188 |
|
189 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
190 |
! ! |
|
191 |
||
25164 | 192 |
!SmalltalkLanguage methodsFor:'queries'! |
193 |
||
194 |
canBeCompiled |
|
195 |
"true if compilable in the browser" |
|
196 |
||
197 |
^ true |
|
198 |
! ! |
|
199 |
||
14374 | 200 |
!SmalltalkLanguage methodsFor:'source queries'! |
201 |
||
24370 | 202 |
bracketStrings |
203 |
"used for autoindent" |
|
204 |
||
205 |
^ #( |
|
206 |
('[' ']') "/ blocks |
|
207 |
) |
|
208 |
||
209 |
"Created: / 26-06-2019 / 22:03:42 / Claus Gittinger" |
|
210 |
! |
|
211 |
||
16420 | 212 |
commentStrings |
213 |
^ #( |
|
214 |
'"/' "/ EOL comment |
|
215 |
('"' '"') "/ normal comment |
|
216 |
) |
|
217 |
! |
|
218 |
||
14374 | 219 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
220 |
"given a selector, return a prototype definition string" |
|
221 |
||
24748 | 222 |
|numArgs| |
223 |
||
224 |
numArgs := aSelector argumentCount. |
|
24863 | 225 |
(numArgs ~~ 0 and:[numArgs == argNames size]) ifTrue:[ |
19893 | 226 |
aSelector isKeywordSelector ifTrue:[ |
19855 | 227 |
^ Text streamContents:[:stream | |
14374 | 228 |
aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
19855 | 229 |
stream bold; nextPutAll:eachKeyword; normal; nextPutAll:eachArgName; space. |
14374 | 230 |
]. |
231 |
stream backStep. "remove the last space" |
|
232 |
]. |
|
233 |
]. |
|
19855 | 234 |
^ aSelector allBold , ' ' , (argNames at:1) |
14374 | 235 |
]. |
19855 | 236 |
^ aSelector allBold |
14374 | 237 |
|
238 |
" |
|
239 |
SmalltalkLanguage instance |
|
240 |
methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
|
241 |
SmalltalkLanguage instance |
|
242 |
methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
|
243 |
SmalltalkLanguage instance |
|
244 |
methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
245 |
" |
|
22668 | 246 |
|
247 |
"Modified: / 12-04-2018 / 08:39:15 / stefan" |
|
24863 | 248 |
"Modified: / 24-10-2019 / 10:53:15 / Stefan Vogel" |
14374 | 249 |
! ! |
250 |
||
11965 | 251 |
!SmalltalkLanguage methodsFor:'testing'! |
252 |
||
253 |
isSmalltalk |
|
12325 | 254 |
"true iff I represent the smalltalk language" |
11965 | 255 |
|
12325 | 256 |
^ true |
11965 | 257 |
|
258 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
259 |
! ! |
|
260 |
||
261 |
!SmalltalkLanguage class methodsFor:'documentation'! |
|
262 |
||
263 |
version |
|
18874 | 264 |
^ '$Header$' |
12047 | 265 |
! |
266 |
||
267 |
version_CVS |
|
18874 | 268 |
^ '$Header$' |
12047 | 269 |
! |
270 |
||
271 |
version_SVN |
|
18874 | 272 |
^'$Id$' |
11965 | 273 |
! ! |
15538 | 274 |