SmalltalkLanguage.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 22 Mar 2023 13:57:18 +0000
branchjv
changeset 25445 1623217d2268
parent 25413 565bf29e3a20
permissions -rw-r--r--
Cherry-picked OrderedCollection.st from 0b286fd51da7: * d4c86d7c0bfc: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 692b6497a669: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * d47bb2912953: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * abb4316c6bff: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 3a8fce0e8d11: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 03d29bf8c5bb: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * cccc6c4abcfc: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 35d957c7a840: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 6b11890f5f2c: #OTHER by cg, Claus Gittinger <cg@exept.de> * abb6108fb06b: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 2c4768bb2e89: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 4029e964d0f1: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ddcab3a9c2df: #OTHER by cg, Claus Gittinger <cg@exept.de> * 2213eb56e0c7: #REFACTORING by exept, Claus Gittinger <cg@exept.de> * 09ca874a6160: #REFACTORING by exept, Claus Gittinger <cg@exept.de> * 30b332af1f33: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 779764ba117b: #REFACTORING by cg, Claus Gittinger <cg@exept.de> * b3d232a613c9: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * c417f7edaec1: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 904b6538f379: #FEATURE by exept, Claus Gittinger <cg@exept.de> * c5887f03e01f: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 8912d03aff48: #BUGFIX by exept, Claus Gittinger <cg@exept.de> * de5cd1dab4c3: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 9bbd26603378: #OTHER by exept, Claus Gittinger <cg@exept.de> * c2c9dc110f42: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 81d123c6703d: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * 8aadbb21458a: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * f210dbb8b2f6: #TUNING by stefan, Stefan Vogel <sv@exept.de> * c2c774fc53c0: #FEATURE by exept, Claus Gittinger <cg@exept.de> * b6f462670875: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 27ae4021d5d6: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 10d9e9d85594: #TUNING by exept, Claus Gittinger <cg@exept.de> * 2653d855dcc7: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 6ea1698a1a34: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 28762315e664: #OTHER by exept, Claus Gittinger <cg@exept.de> * 7142ea786f3e: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 7875acb42b53: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 163a0eebc97e: #BUGFIX by Maren, matilk

"
 COPYRIGHT (c) 2009 by eXept Software AG
 COPYRIGHT (c) 2009 Jan Vrany
 COPYRIGHT (c) 2011 Jan Vrany
 COPYRIGHT (c) 2021 LabWare
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic' }"

"{ NameSpace: Smalltalk }"

ProgrammingLanguage subclass:#SmalltalkLanguage
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Languages'
!

!SmalltalkLanguage class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2009 by eXept Software AG
 COPYRIGHT (c) 2009 Jan Vrany
 COPYRIGHT (c) 2011 Jan Vrany
 COPYRIGHT (c) 2021 LabWare
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    provide info about which tools are to be used for smalltalk code
"
! !

!SmalltalkLanguage methodsFor:'accessing'!

name
    "Answers a human-readable name of myself:
     'Smalltalk' for SmalltalkLanguage,
     'Ruby' for RubyLanguage
     ..."

    ^ 'Smalltalk'

    "Modified: / 16-08-2009 / 10:53:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileSuffix
    "
     Answers a default suffix for source files, i.e.
     'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby'
    "

    ^'st'

    "Modified: / 16-08-2009 / 10:53:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage methodsFor:'accessing-classes'!

codeGeneratorClass
    "Answers a class that can generate code"

    ^ SmalltalkCodeGeneratorTool

    "Created: / 30-01-2011 / 15:19:52 / cg"
!

compilerClass
    "Answer a class suitable for compiling a source code in 'my' language"

    ^ Smalltalk at:#Compiler

    "Modified: / 21-08-2009 / 13:02:27 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

compilerWithBreakpointSupportClass
    "Answer a class suitable for compiling a source code with breakpoints
     in 'my' language"

    ^ ByteCodeCompilerWithBreakpointSupport

    "Created: / 22-07-2013 / 15:46:12 / cg"
!

explainerClass
    "Answers a class used by browser and debugger to
     show some hints about the code. It is OK to return
     nil, which means that there is no explainer for given language."

    "return nil by default"
    ^ Explainer

    "Created: / 21-08-2009 / 08:49:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

formatterClass
    "Answer a class suitable for prettyPrinting (indenting) code in 'my' language.
     It is ok to return nil, which means that the browser will not be able to prettyprint."

    ^ Parser
!

parserClass
    "Answer a class suitable for parsing a source code in 'my' language"

    ^ Parser

    "Modified: / 21-08-2009 / 13:02:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileReaderClass
    "Answers a class that can be used for reading & compiling source files"

    ^SmalltalkChunkFileSourceReader

    "Modified: / 16-08-2009 / 12:29:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

sourceFileWriterClass
    "Answers a class is used for source file writing (i.e. file-out)"

    ^ SmalltalkChunkFileSourceWriter

    "Modified: / 16-08-2009 / 09:51:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

syntaxHighlighterClass
    "return the class to use for syntaxHighlighting (prettyPrinting) this class -
     this can be redefined in special classes, to highlight classes with
     Lisp, Prolog, ASN1, Basic :-) or whatever syntax."

    ^ SyntaxHighlighter
! !

!SmalltalkLanguage methodsFor:'mimicry'!

, anObject
    "Emulates symbol behavior. This is sometimes required
     as 'Smalltalk language' is used by legacy code to access
     the current language setting. 
     Future versions should contain class Locale.
     cg: this is crab, who needs this?
    "
    <resource: #obsolete>

    self obsoleteMethodWarning.
    ^ Smalltalk language , anObject

    "Created: / 22-08-2009 / 09:33:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified (comment): / 01-04-2012 / 13:19:28 / cg"
!

asSymbol
    "Returns a language symbol. This is sometimes required
     as Smalltalk language is used by legacy code to access
     current language. Future versions should contain class
     Locale.
     cg: this is crab, who needs this?
    "
    <resource: #obsolete>

    self obsoleteMethodWarning.
    ^ Smalltalk language

    "Created: / 22-08-2009 / 09:33:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage methodsFor:'source queries'!

commentStrings
    ^ #(
            '"/'          "/ EOL comment
            ('"' '"')     "/ normal comment   
        )
!

methodDefinitionTemplateForSelector:aSelector andArgumentNames:argNames
    "given a selector, return a prototype definition string"

    | spaceAfterKeyword |

    spaceAfterKeyword := (Smalltalk includesKey: #RBFormatter) 
                            ifTrue: [ (Smalltalk at: #RBFormatter) spaceAfterKeywordSelector ]
                            ifFalse:[ false "Smalltalk/X default" ].

    (aSelector numArgs > 0 and:[aSelector numArgs = argNames size]) ifTrue:[
        aSelector isKeywordSelector ifTrue:[
            ^ Text streamContents:[:stream |
                aSelector keywords with:argNames do:[:eachKeyword :eachArgName|
                    stream bold; nextPutAll:eachKeyword; normal.
                    spaceAfterKeyword ifTrue: [ 
                        stream space.
                    ].
                    stream nextPutAll:eachArgName; space.
                ].
                stream backStep.   "remove the last space"
             ].
        ].
        ^ aSelector allBold , ' ' , (argNames at:1)
    ].
    ^ aSelector allBold

    "
     SmalltalkLanguage instance 
        methodDefinitionTemplateForSelector:#foo andArgumentNames:#()
     SmalltalkLanguage instance
        methodDefinitionTemplateForSelector:#+ andArgumentNames:#('aNumber')
     SmalltalkLanguage instance
        methodDefinitionTemplateForSelector:#foo:bar:baz: andArgumentNames:#('fooArg' 'barArg' 'bazArg')
    "

    "Modified: / 05-05-2021 / 10:38:23 / Jan Vrany <jan.vrany@labware.com>"
! !

!SmalltalkLanguage methodsFor:'testing'!

isSmalltalk
    "true iff I represent the smalltalk language"

    ^ true

    "Created: / 16-08-2009 / 09:01:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!SmalltalkLanguage class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^'$Id$'
! !