author | Stefan Vogel <sv@exept.de> |
Thu, 23 Jan 2014 13:58:34 +0100 | |
changeset 15898 | 5b7b19295eb9 |
parent 15538 | d6ae984062ee |
child 16420 | 02e01942d9c2 |
child 18117 | eb433f2c42b2 |
permissions | -rw-r--r-- |
11965 | 1 |
"{ Package: 'stx:libbasic' }" |
2 |
||
3 |
ProgrammingLanguage subclass:#SmalltalkLanguage |
|
4 |
instanceVariableNames:'' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Kernel-Languages' |
|
8 |
! |
|
9 |
||
12100 | 10 |
!SmalltalkLanguage class methodsFor:'documentation'! |
11 |
||
12 |
documentation |
|
13 |
" |
|
14 |
provide info about which tools are to be used for smalltalk code |
|
15 |
" |
|
16 |
! ! |
|
11965 | 17 |
|
18 |
!SmalltalkLanguage methodsFor:'accessing'! |
|
19 |
||
20 |
name |
|
12098 | 21 |
"Answers a human-readable name of myself: |
22 |
'Smalltalk' for SmalltalkLanguage, |
|
23 |
'Ruby' for RubyLanguage |
|
24 |
..." |
|
11965 | 25 |
|
12502 | 26 |
^ 'Smalltalk' |
11965 | 27 |
|
28 |
"Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
29 |
! |
|
30 |
||
31 |
sourceFileSuffix |
|
12098 | 32 |
" |
33 |
Answers a default suffix for source files, i.e. |
|
34 |
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby' |
|
35 |
" |
|
11965 | 36 |
|
37 |
^'st' |
|
38 |
||
39 |
"Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
40 |
! ! |
|
41 |
||
42 |
!SmalltalkLanguage methodsFor:'accessing - classes'! |
|
43 |
||
13259 | 44 |
codeGeneratorClass |
14324
8cb871b96134
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14323
diff
changeset
|
45 |
"Answers a class that can generate code" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
46 |
|
13253
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
47 |
^ SmalltalkCodeGeneratorTool |
4112eccb68e0
changed: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
13249
diff
changeset
|
48 |
|
13259 | 49 |
"Created: / 30-01-2011 / 15:19:52 / cg" |
13249
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
50 |
! |
076097e9faab
added: #codeGeneratorToolClass
Claus Gittinger <cg@exept.de>
parents:
12524
diff
changeset
|
51 |
|
11965 | 52 |
compilerClass |
12098 | 53 |
"Answer a class suitable for compiling a source code in 'my' language" |
11965 | 54 |
|
12098 | 55 |
^ Smalltalk::Compiler |
11965 | 56 |
|
57 |
"Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
58 |
! |
|
59 |
||
15538 | 60 |
compilerWithBreakpointSupportClass |
61 |
"Answer a class suitable for compiling a source code with breakpoints |
|
62 |
in 'my' language" |
|
63 |
||
64 |
^ Smalltalk::ByteCodeCompilerWithBreakpointSupport |
|
65 |
||
66 |
"Created: / 22-07-2013 / 15:46:12 / cg" |
|
67 |
! |
|
68 |
||
11965 | 69 |
explainerClass |
12098 | 70 |
"Answers a class used by browser and debugger to |
71 |
show some hints about the code. It is OK to return |
|
72 |
nil, which means that there is no explainer for given language." |
|
11965 | 73 |
|
74 |
"return nil by default" |
|
12098 | 75 |
^ Smalltalk::Explainer |
11965 | 76 |
|
77 |
"Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
78 |
! |
|
79 |
||
12098 | 80 |
formatterClass |
81 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
82 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
83 |
||
84 |
^ Smalltalk::Parser |
|
85 |
! |
|
86 |
||
11965 | 87 |
parserClass |
12098 | 88 |
"Answer a class suitable for parsing a source codein 'my' language" |
11965 | 89 |
|
12098 | 90 |
^ Smalltalk::Parser |
11965 | 91 |
|
92 |
"Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
93 |
! |
|
94 |
||
95 |
sourceFileReaderClass |
|
12098 | 96 |
"Answers a class that can be used for reading & compiling source files" |
11965 | 97 |
|
98 |
^SmalltalkChunkFileSourceReader |
|
99 |
||
100 |
"Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
101 |
! |
|
102 |
||
103 |
sourceFileWriterClass |
|
12098 | 104 |
"Answers a class is used for source file writing (i.e. file-out)" |
11965 | 105 |
|
12107 | 106 |
^ SmalltalkChunkFileSourceWriter |
11965 | 107 |
|
108 |
"Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12098 | 109 |
! |
110 |
||
111 |
syntaxHighlighterClass |
|
112 |
"return the class to use for syntaxHighlighting (prettyPrinting) this class - |
|
113 |
this can be redefined in special classes, to highlight classes with |
|
114 |
Lisp, Prolog, ASN1, Basic :-) or whatever syntax." |
|
115 |
||
116 |
^ Smalltalk::SyntaxHighlighter |
|
11965 | 117 |
! ! |
118 |
||
119 |
!SmalltalkLanguage methodsFor:'mimicry'! |
|
120 |
||
121 |
, anObject |
|
12098 | 122 |
"Emulates symbol behavior. This is sometimes required |
14069 | 123 |
as 'Smalltalk language' is used by legacy code to access |
124 |
the current language setting. |
|
125 |
Future versions should contain class Locale. |
|
11965 | 126 |
" |
12524 | 127 |
<resource: #obsolete> |
11965 | 128 |
|
15898 | 129 |
self obsoleteMethodWarning. |
12524 | 130 |
^ Language , anObject |
11965 | 131 |
|
132 |
"Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14069 | 133 |
"Modified (comment): / 01-04-2012 / 13:19:28 / cg" |
11965 | 134 |
! |
135 |
||
136 |
asSymbol |
|
12098 | 137 |
"Returns a language symbol. This is sometimes required |
138 |
as Smalltalk language is used by legacy code to access |
|
139 |
current language. Future versions should contain class |
|
140 |
Locale. |
|
11965 | 141 |
" |
12524 | 142 |
<resource: #obsolete> |
11965 | 143 |
|
15898 | 144 |
self obsoleteMethodWarning. |
12524 | 145 |
^ Language |
11965 | 146 |
|
147 |
"Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
148 |
! ! |
|
149 |
||
14374 | 150 |
!SmalltalkLanguage methodsFor:'source queries'! |
151 |
||
152 |
methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames |
|
153 |
"given a selector, return a prototype definition string" |
|
154 |
||
155 |
aSelector numArgs > 0 ifTrue:[ |
|
156 |
aSelector isKeyword ifTrue:[ |
|
157 |
^ String streamContents:[:stream | |
|
158 |
aSelector keywords with:argNames do:[:eachKeyword :eachArgName| |
|
159 |
stream nextPutAll:eachKeyword; nextPutAll:eachArgName; space. |
|
160 |
]. |
|
161 |
stream backStep. "remove the last space" |
|
162 |
]. |
|
163 |
]. |
|
164 |
^ aSelector , ' ' , (argNames at:1) |
|
165 |
]. |
|
166 |
^ aSelector |
|
167 |
||
168 |
" |
|
169 |
SmalltalkLanguage instance |
|
170 |
methodDefinitionTemplateForSelector:#foo andArgumentNames:#() |
|
171 |
SmalltalkLanguage instance |
|
172 |
methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber') |
|
173 |
SmalltalkLanguage instance |
|
174 |
methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg') |
|
175 |
" |
|
176 |
! ! |
|
177 |
||
11965 | 178 |
!SmalltalkLanguage methodsFor:'testing'! |
179 |
||
180 |
isSmalltalk |
|
12325 | 181 |
"true iff I represent the smalltalk language" |
11965 | 182 |
|
12325 | 183 |
^ true |
11965 | 184 |
|
185 |
"Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
186 |
! ! |
|
187 |
||
188 |
!SmalltalkLanguage class methodsFor:'documentation'! |
|
189 |
||
190 |
version |
|
15898 | 191 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.22 2014-01-23 12:58:34 stefan Exp $' |
12047 | 192 |
! |
193 |
||
194 |
version_CVS |
|
15898 | 195 |
^ '$Header: /cvs/stx/stx/libbasic/SmalltalkLanguage.st,v 1.22 2014-01-23 12:58:34 stefan Exp $' |
12047 | 196 |
! |
197 |
||
198 |
version_SVN |
|
15898 | 199 |
^'$Id: SmalltalkLanguage.st,v 1.22 2014-01-23 12:58:34 stefan Exp $' |
11965 | 200 |
! ! |
15538 | 201 |