JavaScriptClassNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 24 Sep 2013 23:18:24 +0200
branchinitialV
changeset 1180 01c6be61f29c
parent 656 21a4b2035a9e
child 752 49a4488b4da3
permissions -rw-r--r--
checkin from stx browser

"
 COPYRIGHT (c) 2005 by eXept Software AG
              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:libjavascript' }"

ParseNode subclass:#JavaScriptClassNode
	instanceVariableNames:'className superClassName privateVariables environment
		staticVariables'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-JavaScript-Compiling & Parsing'
!

!JavaScriptClassNode class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2005 by eXept Software AG
              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.
"
! !

!JavaScriptClassNode methodsFor:'* As yet uncategorized *'!

isInnerFunction
    ^ false
! !

!JavaScriptClassNode methodsFor:'accessing'!

_argVariables
    ^ nil
!

_localVariables
    ^ self _variables
!

_localVariables:aCollection
    self _variables:aCollection
!

_outerEnvironment
    ^ environment

    "Created: / 17.5.1998 / 00:41:00 / cg"
!

_outerEnvironment:anEnvironment
    environment := anEnvironment

    "Created: / 17.5.1998 / 00:41:11 / cg"
!

_variables
    ^ privateVariables
!

_variables:aVariablesEnvironment
    privateVariables := aVariablesEnvironment
!

className
    "return the value of the instance variable 'className' (automatically generated)"

    ^ className
!

className:something
    "set the value of the instance variable 'className' (automatically generated)"

    className := something.
!

staticVariables
    ^ staticVariables
!

staticVariables:something
    staticVariables := something.
!

superClassName
    "return the value of the instance variable 'superClassName' (automatically generated)"

    ^ superClassName
!

superClassName:something
    "set the value of the instance variable 'superClassName' (automatically generated)"

    superClassName := something.
! !

!JavaScriptClassNode methodsFor:'evaluation'!

evaluate
    |superClass oldClass newClass instVarNames classVarNames category environment|

    superClass := Smalltalk at:superClassName asSymbol.
    instVarNames := ''.
    privateVariables size > 0 ifTrue:[
        privateVariables keysAndValuesDo:[:varName :var |
            instVarNames size ~= 0 ifTrue:[
                instVarNames := instVarNames , ' '
            ].
            instVarNames := instVarNames , varName
        ]
    ].
    classVarNames := ''.
    staticVariables size > 0 ifTrue:[
        staticVariables keysAndValuesDo:[:varName :var |
            classVarNames size ~= 0 ifTrue:[
                classVarNames := classVarNames , ' '
            ].
            classVarNames := classVarNames , varName
        ]
    ].
    environment := Class nameSpaceQuerySignal query.
    oldClass := environment classNamed:className.

    category := Class classCategoryQuerySignal query.
"/    oldClass notNil ifTrue:[
"/        category := oldClass category.   
"/    ] ifFalse:[
"/        category := superClass category
"/    ].
    newClass := JavaScriptMetaclass basicNew
            name:(className asSymbol)  
            inEnvironment:environment
            subclassOf:superClass
            instanceVariableNames:instVarNames
            variable:false
            words:false
            pointers:false
            classVariableNames:classVarNames
            poolDictionaries:''
            category:category
            comment:nil
            changed:true. 

    "initialize static variables..."
    staticVariables notNil ifTrue:[
        staticVariables keysAndValuesDo:[:varName :var |
            var expressionForSetup notNil ifTrue:[
                newClass classVarAt: varName put: (var expressionForSetup evaluate).
            ]
        ].
    ].
    ^ newClass

    "Modified: / 17-07-2012 / 12:41:13 / cg"
! !

!JavaScriptClassNode methodsFor:'testing'!

_isFunctionEnvironment
    ^ false

    "Created: / 30-01-2011 / 17:11:10 / cg"
! !

!JavaScriptClassNode methodsFor:'visiting'!

acceptVisitor:visitor 
    "Double dispatch back to the visitor, passing my type encoded in
     the selector (visitor pattern)"

    "stub code automatically generated - please change if required"

    ^ visitor visitJavaScriptClassNode:self 
! !

!JavaScriptClassNode class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !