JavaScriptClassNode.st
author Claus Gittinger <cg@exept.de>
Fri, 21 Feb 2020 20:48:14 +0100
changeset 1231 b7d945ef967a
parent 1198 4fc20702d5bf
permissions -rw-r--r--
#REFACTORING by exept class: JavaScriptParser changed: #forStatement class: JavaScriptParser class added: #forOfAllowed comment/format in: #forInAllowed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
155
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     1
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     2
 COPYRIGHT (c) 2005 by eXept Software AG
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     3
              All Rights Reserved
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     4
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     5
 This software is furnished under a license and may be used
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     6
 only in accordance with the terms of that license and with the
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     8
 be provided or otherwise made available to, or used by, any
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
     9
 other person.  No title to or ownership of the software is
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    10
 hereby transferred.
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    11
"
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libjavascript' }"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
1198
4fc20702d5bf #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
    14
"{ NameSpace: Smalltalk }"
4fc20702d5bf #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
    15
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ParseNode subclass:#JavaScriptClassNode
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    17
	instanceVariableNames:'className superClassName privateVariables environment
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
    18
		staticVariables'
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    21
	category:'Languages-JavaScript-Compiling & Parsing'
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
155
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    24
!JavaScriptClassNode class methodsFor:'documentation'!
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    25
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    26
copyright
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    27
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    28
 COPYRIGHT (c) 2005 by eXept Software AG
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    29
              All Rights Reserved
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    30
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    31
 This software is furnished under a license and may be used
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    32
 only in accordance with the terms of that license and with the
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    34
 be provided or otherwise made available to, or used by, any
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    35
 other person.  No title to or ownership of the software is
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    36
 hereby transferred.
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    37
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 104
diff changeset
    38
! !
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!JavaScriptClassNode methodsFor:'accessing'!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
388
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
    42
_argVariables
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
    43
    ^ nil
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
    44
!
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
    45
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    46
_localVariables
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    47
    ^ self _variables
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    48
!
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    49
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    50
_localVariables:aCollection
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    51
    self _variables:aCollection
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    52
!
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
    53
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
_outerEnvironment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    ^ environment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    "Created: / 17.5.1998 / 00:41:00 / cg"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
_outerEnvironment:anEnvironment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    environment := anEnvironment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "Created: / 17.5.1998 / 00:41:11 / cg"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
_variables
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    ^ privateVariables
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
_variables:aVariablesEnvironment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    privateVariables := aVariablesEnvironment
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
className
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "return the value of the instance variable 'className' (automatically generated)"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    77
    ^ className
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    78
!
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
className:something
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "set the value of the instance variable 'className' (automatically generated)"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    83
    className := something.
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    84
!
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    86
staticVariables
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    87
    ^ staticVariables
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    88
!
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    89
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    90
staticVariables:something
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    91
    staticVariables := something.
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    92
!
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
    93
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
superClassName
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    "return the value of the instance variable 'superClassName' (automatically generated)"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    97
    ^ superClassName
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    98
!
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
superClassName:something
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "set the value of the instance variable 'superClassName' (automatically generated)"
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
   103
    superClassName := something.
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
   104
! !
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!JavaScriptClassNode methodsFor:'evaluation'!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
evaluate
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   109
    "evaluate (i.e. install) a class definition"
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   110
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   111
    |superClass oldClass newClass instVars instVarNames classVarNames category environment
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   112
     firstInitStatement lastInitStatement|
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    superClass := Smalltalk at:superClassName asSymbol.
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   115
    instVars := OrderedCollection new.
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    privateVariables size > 0 ifTrue:[
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   117
        privateVariables keysAndValuesDo:[:varName :var |
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   118
            instVars add:varName.
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   119
        ]
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ].
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   121
    instVarNames := instVars asStringWith:' '.
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   122
    classVarNames := ''.
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   123
    staticVariables size > 0 ifTrue:[
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   124
        staticVariables keysAndValuesDo:[:varName :var |
1198
4fc20702d5bf #TUNING by exept
Claus Gittinger <cg@exept.de>
parents: 770
diff changeset
   125
            classVarNames size ~~ 0 ifTrue:[
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   126
                classVarNames := classVarNames , ' '
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   127
            ].
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   128
            classVarNames := classVarNames , varName
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   129
        ]
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   130
    ].
104
3ed1e2ef71ca *** empty log message ***
ca
parents: 83
diff changeset
   131
    environment := Class nameSpaceQuerySignal query.
3ed1e2ef71ca *** empty log message ***
ca
parents: 83
diff changeset
   132
    oldClass := environment classNamed:className.
3ed1e2ef71ca *** empty log message ***
ca
parents: 83
diff changeset
   133
388
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   134
    category := Class classCategoryQuerySignal query.
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   135
"/    oldClass notNil ifTrue:[
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   136
"/        category := oldClass category.   
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   137
"/    ] ifFalse:[
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   138
"/        category := superClass category
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   139
"/    ].
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   140
    newClass := JavaScriptMetaclass new
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   141
            name:(className asSymbol)  
104
3ed1e2ef71ca *** empty log message ***
ca
parents: 83
diff changeset
   142
            inEnvironment:environment
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   143
            subclassOf:superClass
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   144
            instanceVariableNames:instVarNames
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   145
            variable:false
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   146
            words:false
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   147
            pointers:false
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   148
            classVariableNames:classVarNames
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   149
            poolDictionaries:''
104
3ed1e2ef71ca *** empty log message ***
ca
parents: 83
diff changeset
   150
            category:category
83
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   151
            comment:nil
d660cc428b0e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   152
            changed:true. 
529
a85eb3da47f6 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
   153
a85eb3da47f6 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
   154
    "initialize static variables..."
533
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   155
    staticVariables notNil ifTrue:[
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   156
        staticVariables keysAndValuesDo:[:varName :var |
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   157
            var expressionForSetup notNil ifTrue:[
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   158
                newClass classVarAt: varName put: (var expressionForSetup evaluate).
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   159
            ]
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   160
        ].
529
a85eb3da47f6 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 502
diff changeset
   161
    ].
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   162
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   163
    "/ if any var has an init-expression, generate an initializer method 
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   164
    firstInitStatement := lastInitStatement := nil.
770
d536f949d37a class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   165
    (privateVariables ? #()) keysAndValuesDo:[:varName :var |
753
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   166
        |varNode initStatement|
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   167
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   168
        var expressionForSetup notNil ifTrue:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   169
            varNode := JavaScriptVariableNode 
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   170
                            type:#InstanceVariable
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   171
                            name:var name
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   172
                            token:var
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   173
                            index:(instVars indexOf:var name).
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   174
            initStatement := JavaScriptParser::JavaScriptStatementNode new
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   175
                                expression:(JavaScriptParser::JavaScriptAssignmentNode variable:varNode expression:var expressionForSetup).
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   176
            firstInitStatement isNil ifTrue:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   177
                firstInitStatement := initStatement
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   178
            ] ifFalse:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   179
                lastInitStatement nextStatement:initStatement
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   180
            ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   181
            lastInitStatement := initStatement
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   182
        ]
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   183
    ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   184
    firstInitStatement notNil ifTrue:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   185
        |stat1 stat2 fn|
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   186
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   187
        fn := JavaScriptFunctionNode new.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   188
        fn functionName:'__initialize__'.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   189
        superClass == Object ifTrue:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   190
            stat1 := firstInitStatement.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   191
        ] ifFalse:[
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   192
            stat1 := JavaScriptParser::JavaScriptStatementNode new
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   193
                        expression:((JavaScriptParser::FunctionCallNode
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   194
                                        receiver:(SuperNode new)
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   195
                                        selector:'__initialize__')
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   196
                                        javaScriptSelector:'__initialize__').
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   197
            stat1 nextStatement:firstInitStatement.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   198
        ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   199
        stat2 := JavaScriptParser::JavaScriptReturnNode new
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   200
                    expression:(JavaScriptParser::ThisNode new).
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   201
        lastInitStatement nextStatement:stat2.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   202
        fn statements:stat1.
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   203
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   204
        JavaScriptCompiler new
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   205
             compileTree:fn source:(fn printString) forClass:newClass inCategory:'initialization' notifying:nil
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   206
                 install:true skipIfSame:false silent:true foldConstants:true
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   207
                 ifFail:[ self halt ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   208
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   209
        JavaScriptCompiler new
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   210
             compile:'function new() {
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   211
    return (this.basicNew().__initialize__().initialize());
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   212
}'
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   213
                 forClass:newClass class inCategory:'instance creation' notifying:nil
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   214
                 install:true skipIfSame:false silent:true foldConstants:true
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   215
                 ifFail:[ self halt ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   216
    ].
2348c03d8585 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 752
diff changeset
   217
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    ^ newClass
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   219
533
ba52876e9056 changed: #evaluate
Claus Gittinger <cg@exept.de>
parents: 529
diff changeset
   220
    "Modified: / 17-07-2012 / 12:41:13 / cg"
502
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   221
! !
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   222
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   223
!JavaScriptClassNode methodsFor:'testing'!
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   224
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   225
_isFunctionEnvironment
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   226
    ^ false
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   227
e2b30cb252a1 +staticVariables
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   228
    "Created: / 30-01-2011 / 17:11:10 / cg"
752
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   229
!
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   230
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   231
isInnerFunction
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   232
    ^ false
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   233
!
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   234
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   235
isJavaScriptClassNode
49a4488b4da3 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 656
diff changeset
   236
    ^ true
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
! !
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
656
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   239
!JavaScriptClassNode methodsFor:'visiting'!
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   240
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   241
acceptVisitor:visitor 
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   242
    "Double dispatch back to the visitor, passing my type encoded in
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   243
     the selector (visitor pattern)"
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   244
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   245
    "stub code automatically generated - please change if required"
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   246
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   247
    ^ visitor visitJavaScriptClassNode:self 
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   248
! !
21a4b2035a9e Added JavaScriptParseNodeVisitor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 643
diff changeset
   249
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
!JavaScriptClassNode class methodsFor:'documentation'!
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
version
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    ^ '$Header$'
388
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   254
!
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   255
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   256
version_CVS
a87442ba8c93 cate for category
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   257
    ^ '$Header$'
39
bfb1e7545090 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
! !
643
2cde750704e9 class: JavaScriptClassNode
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   259