JavaScriptCompiler.st
author Claus Gittinger <cg@exept.de>
Fri, 21 Feb 2020 20:48:14 +0100
changeset 1231 b7d945ef967a
parent 1227 3210fc572401
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: 143
diff changeset
     1
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
     2
 COPYRIGHT (c) 2005 by eXept Software AG
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
     3
	      All Rights Reserved
155
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
     4
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
     5
 This software is furnished under a license and may be used
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
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: 143
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
     8
 be provided or otherwise made available to, or used by, any
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
     9
 other person.  No title to or ownership of the software is
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    10
 hereby transferred.
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    11
"
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libjavascript' }"
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
857
7933834a28d8 class: JavaScriptCompiler
ca
parents: 837
diff changeset
    14
"{ NameSpace: Smalltalk }"
7933834a28d8 class: JavaScriptCompiler
ca
parents: 837
diff changeset
    15
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
JavaScriptParser subclass:#JavaScriptCompiler
396
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
    17
	instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
    18
		maxStackDepth relocList methodTempVars numTemp maxNumTemp
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
    19
		methodClass loopStack currentLineNumber'
354
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
    20
	classVariableNames:'JumpToAbsJump'
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
47
684f35c49db2 category change
Claus Gittinger <cg@exept.de>
parents: 40
diff changeset
    22
	category:'Languages-JavaScript-Compiling & Parsing'
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    25
Object subclass:#LoopDescription
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    26
	instanceVariableNames:'breakLabel continueLabel backPatchListForBreak
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    27
		backPatchListForContinue'
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    28
	classVariableNames:''
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    29
	poolDictionaries:''
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    30
	privateIn:JavaScriptCompiler
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    31
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
    32
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    33
Object subclass:#LoopDescriptionForBlock
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
    34
	instanceVariableNames:'deltaScope'
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    35
	classVariableNames:''
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    36
	poolDictionaries:''
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    37
	privateIn:JavaScriptCompiler
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    38
!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
    39
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    40
JavaScriptCompiler::LoopDescription subclass:#SwitchDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    41
	instanceVariableNames:''
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    42
	classVariableNames:''
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    43
	poolDictionaries:''
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    44
	privateIn:JavaScriptCompiler
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    45
!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
    46
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    47
!JavaScriptCompiler class methodsFor:'documentation'!
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    48
155
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    49
copyright
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    50
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    51
 COPYRIGHT (c) 2005 by eXept Software AG
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    52
	      All Rights Reserved
155
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    53
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    54
 This software is furnished under a license and may be used
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    55
 only in accordance with the terms of that license and with the
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    56
 inclusion of the above copyright notice.   This software may not
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    57
 be provided or otherwise made available to, or used by, any
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    58
 other person.  No title to or ownership of the software is
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    59
 hereby transferred.
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    60
"
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    61
!
8941ab2fe811 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 143
diff changeset
    62
592
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    63
documentation
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    64
"
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    65
    JavaScriptCompiler has a lot of stuff copied from ByteCodeCompiler.
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    66
    This is a very BAD SMELL!!
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    67
"
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    68
!
ce72a22284ba class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 590
diff changeset
    69
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    70
examples
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    71
"
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    72
				    [exBegin]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    73
    |f|
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    74
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    75
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    76
	compile:'max(a, b) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    77
		    if (a > b) return a;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    78
		    return b;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    79
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    80
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    81
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    82
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    83
    f valueWithReceiver:nil arguments:#(10 20).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    84
				    [exEnd]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    85
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    86
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    87
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    88
				    [exBegin]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    89
    |f|
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    90
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
    91
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    92
	compile:'max(a, b) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    93
		    if (a > b) ;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    94
		    else return b;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    95
		    return a;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    96
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    97
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    98
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    99
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   100
    f valueWithReceiver:nil arguments:#(10 20).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   101
				    [exEnd]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   102
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   103
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   104
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   105
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   106
				    [exBegin]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   107
    |f|
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   108
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   109
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   110
	compile:'max(a, b) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   111
		    if (a > b) return a;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   112
		    else return b;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   113
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   114
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   115
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   116
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   117
    f valueWithReceiver:nil arguments:#(20 10).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   118
				    [exEnd]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   119
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   120
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   121
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   122
				    [exBegin]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   123
    |f|
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   124
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   125
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   126
	compile:('test(arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   127
		    var n;
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   128
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   129
		    n = arg;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   130
		    while (n > 0) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   131
			n--;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   132
			Transcript.showCR(#hello#);
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   133
		    }
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   134
		 }' replaceAll:$# with:Character doubleQuote)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   135
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   136
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   137
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   138
    f valueWithReceiver:nil arguments:#(5).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   139
				    [exEnd]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   140
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   141
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   142
				    [exBegin]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   143
    |f|
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   144
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   145
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   146
	compile:('test(arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   147
		    var n;
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   148
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   149
		    n = 1;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   150
		    while (n <= arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   151
			n++;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   152
			Transcript.showCR(#hello#);
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   153
		    }
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   154
		 }' replaceAll:$# with:Character doubleQuote)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   155
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   156
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   157
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   158
    f valueWithReceiver:nil arguments:#(5).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   159
				    [exEnd]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   160
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   161
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   162
				    [exBegin]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   163
    |f|
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   164
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   165
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   166
	compile:'test(arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   167
		    var n;
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   168
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   169
		    n = 1;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   170
		    while (n <= arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   171
			Transcript.showCR(n++);
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   172
		    }
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   173
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   174
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   175
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   176
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   177
    f valueWithReceiver:nil arguments:#(5).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   178
				    [exEnd]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   179
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   180
				    [exBegin]
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   181
    |f|
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   182
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   183
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   184
	compile:'test(arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   185
		    var n;
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
   186
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   187
		    n = 1;
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   188
		    while (n++ <= arg) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   189
			Transcript.showCR(n);
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   190
		    }
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   191
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   192
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   193
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   194
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   195
    f valueWithReceiver:nil arguments:#(5).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   196
				    [exEnd]
171
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   197
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   198
				    [exBegin]
171
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   199
    |f|
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   200
ab98a8121b9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
   201
    f := JavaScriptCompiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   202
	compile:'foo() {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   203
		    Transcript.showCR(''start'');
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   204
		    try {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   205
			Error.raise();
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   206
		    } catch(Error) {
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   207
			Transcript.showCR(''caught error'');
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   208
		    };
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   209
		    Transcript.showCR(''end'');
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   210
		 }'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   211
	forClass:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   212
	inCategory:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   213
	notifying:nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   214
    f valueWithReceiver:nil arguments:#().
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   215
				    [exEnd]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   216
"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   217
! !
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
748
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   219
!JavaScriptCompiler class methodsFor:'instance creation'!
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   220
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   221
new
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   222
    "/ Pretty ugly hack. A caller to compiler may provide a set of breakpoints
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   223
    "/ that has to be injected to the code. However, since breakpoint injection
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   224
    "/ is actually done by a subclass or me, so we have to return this subclass here.
1095
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   225
    "/ This subclass-to-transform API is bit unfortunate.
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   226
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   227
    | breakpoints |
748
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   228
1095
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   229
    self == JavaScriptCompiler ifTrue:[
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   230
        breakpoints := BreakpointQuery query.
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   231
        breakpoints notEmptyOrNil ifTrue:[
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   232
            ^ JavaScriptCompilerWithBreakpointSupport new
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   233
                breakpoints: breakpoints;
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   234
                yourself.
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   235
        ].
748
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   236
    ].
1095
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   237
    ^ super new.
748
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   238
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   239
    "Created: / 08-05-2014 / 11:01:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   240
    "Modified (comment): / 08-05-2014 / 13:56:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1095
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
   241
    "Modified: / 27-06-2019 / 10:05:48 / Claus Gittinger"
748
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   242
! !
78d0788cea93 Added breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 726
diff changeset
   243
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   244
!JavaScriptCompiler class methodsFor:'compiling methods'!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   245
501
b6ec5ca2dacd added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   246
compile:aString forClass:aClass inCategory:cat
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   247
    ^ self
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   248
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   249
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   250
	inCategory:cat
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   251
	notifying:nil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   252
	install:true
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   253
	skipIfSame:false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   254
	silent:false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   255
	foldConstants:true
501
b6ec5ca2dacd added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   256
b6ec5ca2dacd added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   257
    "Created: / 30-01-2011 / 16:59:00 / cg"
b6ec5ca2dacd added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   258
!
b6ec5ca2dacd added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 462
diff changeset
   259
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   260
compile:aString forClass:aClass inCategory:cat notifying:requestor
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   261
    "compile a source-string for a method in classToCompileFor.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   262
     errors are forwarded to requestor.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   263
     The method will get cat as category.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   264
     Returns the new method, #Error or nil."
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   265
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   266
    ^ self
40
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   267
	compile:aString
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   268
	forClass:aClass
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   269
	inCategory:cat
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   270
	notifying:requestor
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   271
	install:true
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   272
	skipIfSame:false
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   273
	silent:false
382a209e9150 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 38
diff changeset
   274
	foldConstants:true
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   275
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   276
93
10f5a8dfc71b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   277
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   278
    ^ self
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   279
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   280
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   281
	inCategory:cat
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   282
	notifying:requestor
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   283
	install:install
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   284
	skipIfSame:false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   285
	silent:false
93
10f5a8dfc71b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   286
!
10f5a8dfc71b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   287
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   288
compile:aString forClass:aClass inCategory:cat notifying:requestor
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   289
		 install:install skipIfSame:skipIfSame silent:silent
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   290
    "compile a source-string for a method in aClass.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   291
     errors are forwarded to requestor.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   292
     The method will get cat as category.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   293
     if install is true, the method is installed in the class.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   294
     if skipIfSame, the method is not installed if there is no change
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   295
     (used when filing in).
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   296
     if silent is true, no warnings are output.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   297
     Returns the new method, #Error or nil."
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   298
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   299
    ^ self
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   300
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   301
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   302
	inCategory:cat
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   303
	notifying:requestor
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   304
	install:install
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   305
	skipIfSame:skipIfSame
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   306
	silent:silent
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   307
	foldConstants:true
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   308
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   309
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   310
compile:aString forClass:aClass inCategory:cat notifying:requestor
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   311
		 install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   312
    |compiler |
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   313
509
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   314
    compiler := self new.
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   315
    "/ not needed...
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   316
    "/ compiler := self for:(ReadStream on:aString).
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   317
    "/ compiler setClassToCompileFor:aClass.
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   318
    "/ compiler nextToken.
58
73e10a59fa4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 57
diff changeset
   319
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   320
    ^ compiler
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   321
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   322
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   323
	inCategory:cat
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   324
	notifying:requestor
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   325
	install:install
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   326
	skipIfSame:skipIfSame
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   327
	silent:silent
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   328
	foldConstants:fold
509
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   329
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
   330
    "Modified: / 30-09-2011 / 12:49:29 / cg"
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   331
!
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   332
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   333
compile:aString in:aClass notifying:requestor ifFail:failBlock
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   334
    |newMethod|
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   335
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   336
    newMethod := self
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   337
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   338
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   339
	inCategory:'no category'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   340
	notifying:requestor
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   341
	install:true
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   342
	skipIfSame:false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   343
	silent:false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   344
	foldConstants:true.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
   345
    newMethod == #Error ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   346
	^ failBlock value
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   347
    ].
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   348
    ^ newMethod
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   349
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   350
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   351
evaluate:aString notifying:requestor compile:doCompile
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   352
    "used to install new classes"
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   353
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   354
    |tree|
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   355
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   356
    tree := self parseClassDefinition:aString.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   357
    ^ tree evaluate.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   358
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   359
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   360
newCodeSet
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   361
    ^ true
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   362
! !
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   363
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   364
!JavaScriptCompiler class methodsFor:'private'!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   365
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   366
selectorFor:functionName numArgs:nargs
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   367
    (nargs == 1) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
   368
        ^ (functionName , ':') asSymbol.
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   369
    ].
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   370
    (nargs == 2) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
   371
        ^ (functionName , ':_:') asSymbol.
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   372
    ].
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   373
    (nargs == 3) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
   374
        ^ (functionName , ':_:_:') asSymbol.
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   375
    ].
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   376
    ^ (functionName , (':_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:' copyTo:nargs*2-1)) asSymbol.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   377
! !
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   378
608
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   379
!JavaScriptCompiler methodsFor:'accessing'!
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   380
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   381
methodClass:something
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   382
    methodClass := something.
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   383
! !
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
   384
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   385
!JavaScriptCompiler methodsFor:'code generation'!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   386
354
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   387
absJumpFromJump:code
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   388
    "given a jump-symbolic code, return corresponding absolute jump"
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   389
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   390
    JumpToAbsJump isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   391
	JumpToAbsJump := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   392
	JumpToAbsJump at:#jump put:#jumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   393
	JumpToAbsJump at:#trueJump put:#trueJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   394
	JumpToAbsJump at:#falseJump put:#falseJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   395
	JumpToAbsJump at:#nilJump put:#nilJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   396
	JumpToAbsJump at:#notNilJump put:#notNilJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   397
	JumpToAbsJump at:#eqJump put:#eqJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   398
	JumpToAbsJump at:#notEqJump put:#notEqJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   399
	JumpToAbsJump at:#zeroJump put:#zeroJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   400
	JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   401
	JumpToAbsJump at:#makeBlock put:#makeBlockabs.
354
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   402
    ].
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   403
    ^ JumpToAbsJump at:code
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   404
!
108ea96ce6b6 missing absJumpFromJump: (long JS-functions crash report from swisscom)
Claus Gittinger <cg@exept.de>
parents: 248
diff changeset
   405
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   406
addLiteral:anObject
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   407
    "add a literal to the literalArray - watch for and eliminate
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   408
     duplicates. return the index of the literal in the Array"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   409
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   410
    |index "{ Class: SmallInteger }" oldLit class|
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   411
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   412
    litArray isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   413
	litArray := Array with:anObject.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   414
	^ 1
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   415
    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   416
    index := litArray identityIndexOf:anObject.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   417
    (index == 0) ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   418
	"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   419
	 reuse constants if same value and same class
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   420
	"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   421
	class := anObject class.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   422
	((class == Float)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   423
	or:[class == Fraction
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   424
	or:[class == LargeInteger
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   425
	"or:[class == String] --only if literalString option has been added---" ]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   426
	    index := litArray indexOf:anObject.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   427
	    index ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   428
		oldLit := litArray at:index.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   429
		oldLit class == class ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   430
		    index := 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   431
		] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   432
		    "/ dont mess up negative with positive zeros
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   433
		    anObject = 0.0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   434
			anObject isNegativeZero ~~ oldLit isNegativeZero ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   435
			    index := 0
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   436
			]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   437
		    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   438
		].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   439
	    ].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   440
	].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   441
	(index == 0) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   442
	    litArray := litArray copyWith:anObject.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   443
	    ^ litArray size
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   444
	].
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   445
    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   446
    ^ index
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   447
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   448
    "Modified: / 12.11.1997 / 18:49:43 / cg"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   449
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   450
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   451
addReloc:symIndex
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   452
    "remember to relocate offset at symIndex later ..."
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   453
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   454
    relocList isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   455
	relocList := OrderedCollection new.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   456
    ].
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   457
    relocList add:symIndex
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   458
!
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
   459
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   460
appendByte:aByte
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   461
    "append a byte to the code-Array, checking for byte-range (debug-only)"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   462
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   463
    |idx "{Class: SmallInteger }"|
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   464
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   465
    idx := codeIndex.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   466
    (aByte between:0 and:255) ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   467
	codeBytes at:idx put:aByte.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   468
	codeIndex := idx + 1
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   469
    ] ifFalse:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   470
	self error:'byte range error'.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   471
	errorFlag := #Error
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   472
    ]
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   473
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   474
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   475
appendByteCodeFor:codeSymbol
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   476
    "append the byteCode for an instructionSymbol to the code-Array"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   477
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   478
    |idx "{Class: SmallInteger }"|
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   479
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   480
    idx := codeIndex.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   481
    codeBytes at:idx put:(self byteCodeFor:codeSymbol).
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   482
    codeIndex := idx + 1
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   483
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   484
124
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   485
appendEmptyByte
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   486
    "append an empty byte to the code-Array"
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   487
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   488
    |idx "{Class: SmallInteger }"|
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   489
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   490
    idx := codeIndex.
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   491
    codeBytes at:idx put:0.
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   492
    codeIndex := idx + 1
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   493
!
e09d8d40d799 inner functions
Claus Gittinger <cg@exept.de>
parents: 111
diff changeset
   494
57
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   495
appendSignedByte:aByte
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   496
    "append a signedbyte (as in jump-offsets) to the code-Array,
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   497
     check range and report an error if invalid"
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   498
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   499
    |b   "{Class: SmallInteger }"
57
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   500
     idx "{Class: SmallInteger }"|
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   501
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   502
    idx := codeIndex.
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   503
    b := aByte.
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   504
    (b >= 0) ifTrue:[
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   505
	(b > 127) ifTrue:[
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   506
	    self error:'jump-range error'.
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   507
	    errorFlag := #Error
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   508
	].
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   509
	codeBytes at:idx put:b
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   510
    ] ifFalse:[
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   511
	(b < -128) ifTrue:[
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   512
	    self error:'jump-range error'.
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   513
	    errorFlag := #Error
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   514
	].
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   515
	b := 256 + b
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   516
    ].
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   517
    codeBytes at:idx put:b.
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   518
    codeIndex := idx + 1
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   519
!
aeee0ce4a8dd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 51
diff changeset
   520
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   521
appendSignedWord:aWord
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   522
    "append a signed word to the code-Array,
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   523
     check range and report an error if invalid"
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   524
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   525
    |w   "{Class: SmallInteger }"|
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   526
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   527
    w := aWord.
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   528
    (w >= 0) ifTrue:[
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   529
	(w > 16r7FFF) ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   530
	    self error:'word-range error'.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   531
	    errorFlag := #Error
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   532
	].
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   533
    ] ifFalse:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   534
	(w < 16r-8000) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   535
	    self error:'word-range error'.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   536
	    errorFlag := #Error
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   537
	].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   538
	w := (16r10000 + w).
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   539
    ].
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   540
    self appendWord:w
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   541
!
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   542
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   543
appendWord:aWord
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   544
    "append an unsigned word (low-high) to the code-Array,
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   545
     checking for word-range (debug-only)"
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   546
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   547
    |idx "{Class: SmallInteger }"|
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   548
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   549
    idx := codeIndex.
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   550
    (aWord between:0 and:16rFFFF) ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   551
	codeBytes at:idx put:(aWord bitAnd:16rFF).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   552
	idx := idx + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   553
	codeBytes at:idx put:(aWord bitShift:-8).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   554
	codeIndex := idx + 1
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   555
    ] ifFalse:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   556
	self error:'word range error'.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   557
	errorFlag := #Error
156
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   558
    ]
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   559
!
76e284bce2c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
   560
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   561
byteCodeFor:aSymbol
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   562
    "given a symbolic instruction, return the corresponding bytecode.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   563
     as a side-effect, leave number of bytes pushed/popped by this instr.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   564
     in stackDelta, and, if the instruction needs extra arguments, leave
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   565
     this info in extra. Also lineno is set to true, if this code has line
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   566
     information and extraLiteral is set if any hidden send is performed by it."
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   567
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   568
    "standard bytecodes"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   569
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   570
    (aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   571
    (aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   572
    (aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   573
    (aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   574
    (aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   575
    (aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   576
    (aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   577
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   578
    (aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   579
    (aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   580
    (aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   581
    (aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   582
    (aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   583
    (aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   584
    (aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   585
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   586
    (aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   587
    (aSymbol == #retSelf) ifTrue:[^5].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   588
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   589
    (aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   590
    (aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   591
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   592
    (aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   593
    (aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   594
    (aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   595
    (aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   596
    (aSymbol == #jump) ifTrue:[extra := #offset. ^ 54].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   597
    (aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   598
    (aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   599
    (aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   600
    (aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   601
    (aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   602
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   603
    (aSymbol == #lineno) ifTrue:[lineno := true. ^ 8].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   604
    (aSymbol == #lineno16) ifTrue:[lineno := true. ^ 9].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   605
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   606
    (aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   607
    (aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   608
    (aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   609
    (aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   610
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   611
    (aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   612
    (aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   613
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   614
    (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   615
    (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   616
    (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
519
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   617
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   618
    "/ the next 2 are to be obsoleted soon (renamed as MethodLocal)
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   619
    (aSymbol == #pushLocal) ifTrue:[ stackDelta := 1. extra := #index. ^ 239].
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   620
    (aSymbol == #storeLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 240].
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   621
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   622
    (aSymbol == #pushMethodLocal) ifTrue:[ stackDelta := 1. extra := #index. ^ 239].
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   623
    (aSymbol == #storeMethodLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 240].
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   624
    (aSymbol == #storeBlockLocal) ifTrue:[ stackDelta := -1. extra := #index. ^ 241].
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   625
    (aSymbol == #storeOuterBlockLocal) ifTrue:[ stackDelta := -1. extra := #indexLevel. ^ 242].
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   626
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   627
    (aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   628
    (aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 36].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   629
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   630
    (aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   631
    (aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 41].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   632
    (aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   633
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   634
    (aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   635
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   636
    (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   637
    (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   638
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   639
    "optimized bytecodes"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   640
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   641
    (aSymbol == #retNil) ifTrue:[^ 1].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   642
    (aSymbol == #retTrue) ifTrue:[^ 2].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   643
    (aSymbol == #retFalse) ifTrue:[^ 3].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   644
    (aSymbol == #ret0) ifTrue:[^ 4].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   645
    (aSymbol == #retNum) ifTrue:[extra := #number. ^ 127].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   646
    (aSymbol == #homeRetTop) ifTrue:[^ 7].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   647
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   648
    (aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   649
    (aSymbol == #push0) ifTrue:[stackDelta := 1. ^120].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   650
    (aSymbol == #push1) ifTrue:[stackDelta := 1. ^121].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   651
    (aSymbol == #push2) ifTrue:[stackDelta := 1. ^139].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   652
    (aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   653
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   654
    (aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   655
    (aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   656
    (aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   657
    (aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   658
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   659
    (aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   660
    (aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   661
    (aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   662
    (aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   663
    (aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   664
    (aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   665
    (aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   666
    (aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   667
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   668
    (aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   669
    (aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   670
    (aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   671
    (aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   672
    (aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   673
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   674
    (aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   675
    (aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   676
    (aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   677
    (aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   678
    (aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   679
    (aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   680
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   681
    (aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   682
    (aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   683
    (aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   684
    (aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   685
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   686
    (aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   687
    (aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   688
    (aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   689
    (aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   690
    (aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   691
    (aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   692
    (aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   693
    (aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   694
    (aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   695
    (aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   696
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   697
    (aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   698
    (aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   699
    (aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   700
    (aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   701
    (aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   702
    (aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   703
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   704
    (aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   705
    (aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   706
    (aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   707
    (aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   708
    (aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   709
    (aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   710
    (aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   711
    (aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   712
    (aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   713
    (aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   714
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   715
    (aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   716
    (aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   717
    (aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   718
    (aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   719
    (aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   720
    (aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   721
    (aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   722
    (aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   723
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   724
    (aSymbol == #retMethodVar1) ifTrue:[^160].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   725
    (aSymbol == #retMethodVar2) ifTrue:[^161].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   726
    (aSymbol == #retMethodVar3) ifTrue:[^162].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   727
    (aSymbol == #retMethodVar4) ifTrue:[^163].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   728
    (aSymbol == #retMethodVar5) ifTrue:[^164].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   729
    (aSymbol == #retMethodVar6) ifTrue:[^165].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   730
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   731
    (aSymbol == #retInstVar1) ifTrue:[^166].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   732
    (aSymbol == #retInstVar2) ifTrue:[^167].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   733
    (aSymbol == #retInstVar3) ifTrue:[^168].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   734
    (aSymbol == #retInstVar4) ifTrue:[^169].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   735
    (aSymbol == #retInstVar5) ifTrue:[^170].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   736
    (aSymbol == #retInstVar6) ifTrue:[^171].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   737
    (aSymbol == #retInstVar7) ifTrue:[^172].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   738
    (aSymbol == #retInstVar8) ifTrue:[^173].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   739
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   740
    (aSymbol == #retMethodArg1) ifTrue:[^174].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   741
    (aSymbol == #retMethodArg2) ifTrue:[^175].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   742
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   743
    (aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   744
    (aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   745
    (aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   746
    (aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   747
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   748
    (aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   749
    (aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   750
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   751
    (aSymbol == #=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^130].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   752
    (aSymbol == #+) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^131].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   753
    (aSymbol == #~=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^132].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   754
    (aSymbol == #-) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^133].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   755
    (aSymbol == #*) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^230].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   756
    (aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   757
"/    (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   758
"/    (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   759
"/    (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   760
"/    (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   761
"/    (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   762
"/    (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   763
    (aSymbol == #at:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^135].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   764
    (aSymbol == #at:put:)ifTrue:[lineno := true. stackDelta := -2. extraLiteral := aSymbol. ^136].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   765
    (aSymbol == #bitAnd:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^137].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   766
    (aSymbol == #bitOr:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^138].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   767
    (aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   768
    (aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   769
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   770
    (aSymbol == #incMethodVar) ifTrue:[lineno := true. extraLiteral := #+. extra := #index. ^125].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   771
    (aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   772
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   773
    (aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   774
    (aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   775
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   776
    (aSymbol == #>) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 145].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   777
    (aSymbol == #>=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 146].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   778
    (aSymbol == #<) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 147].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   779
    (aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   780
"/    (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   781
"/    (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   782
    (aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   783
    (aSymbol == #value:) ifTrue:[lineno := true. extraLiteral := aSymbol.  stackDelta := -1. ^ 152].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   784
    (aSymbol == #value:value:) ifTrue:[lineno := true. extraLiteral := aSymbol.  stackDelta := -2. ^ 178].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   785
    (aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   786
"/    (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   787
"/    (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   788
    (aSymbol == #mk0Block) ifTrue:[^ 156].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   789
    (aSymbol == #mkNilBlock) ifTrue:[^ 157].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   790
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   791
    (aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   792
    (aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. extraLiteral := #>. ^ 208].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   793
    (aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   794
    (aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   795
    (aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   796
    (aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   797
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   798
    (aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   799
    (aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   800
    (aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   801
    (aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   802
    (aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   803
    (aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   804
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   805
    (aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   806
    (aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   807
    (aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   808
    (aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   809
    (aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   810
    (aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   811
    (aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   812
    (aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   813
    (aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   814
    (aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   815
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   816
    (aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   817
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   818
    (aSymbol == #isNil) ifTrue:[extraLiteral := aSymbol. ^ 188].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   819
    (aSymbol == #notNil) ifTrue:[extraLiteral := aSymbol. ^ 189].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   820
    (aSymbol == #not) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 179].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   821
    (aSymbol == #&) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 216].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   822
    (aSymbol == #|) ifTrue:[extraLiteral := aSymbol. lineno := true. ^ 217].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   823
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   824
    (aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   825
    (aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   826
    (aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   827
    (aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   828
    (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   829
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   830
    (aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   831
    (aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   832
    (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   833
    (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   834
    (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   835
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   836
    (aSymbol == #top) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   837
    (aSymbol == #bottom) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   838
    (aSymbol == #left) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   839
    (aSymbol == #right) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   840
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   841
    (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   842
    (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   843
    (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   844
    (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   845
    (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   846
    (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   847
    (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   848
    (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   849
    (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   850
    (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   851
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   852
    (aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   853
    (aSymbol == #over) ifTrue:[stackDelta := 1. ^ 6].
590
fbeea17273d2 class: JavaScriptCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 582
diff changeset
   854
    (aSymbol == #swap) ifTrue:[stackDelta := 0. ^ 243].
fbeea17273d2 class: JavaScriptCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 582
diff changeset
   855
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   856
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   857
    self error:'invalid code symbol'.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   858
    errorFlag := #Error
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   859
239
8db5212859c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
   860
    "Modified: / 03-09-1995 / 12:58:47 / claus"
519
7650b5d049ea changed: #byteCodeFor:
Claus Gittinger <cg@exept.de>
parents: 509
diff changeset
   861
    "Modified: / 31-10-2011 / 11:35:07 / cg"
590
fbeea17273d2 class: JavaScriptCompiler
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 582
diff changeset
   862
    "Modified: / 09-05-2013 / 12:12:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   863
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   864
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   865
code
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   866
    ^ codeBytes
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   867
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   868
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   869
codeLineNumber:nr on:codeStream
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   870
    "generate lineNumber information"
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   871
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   872
    "/ caveat: (currently) there is no separate lineNumber or symbol table;
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   873
    "/ the line numbers are coded right into the instruction stream.
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   874
    "/ This might change in the future.
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   875
    "/ (It is not a problem speed wise: the Jitter just skips them.)
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   876
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   877
    (currentLineNumber = nr or:[nr <= 0]) ifTrue:[
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   878
	^ self
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   879
    ].
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   880
602
1d3d1456dffe class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 601
diff changeset
   881
    "don't need line number information, if still on same line"
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   882
    currentLineNumber := nr.
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   883
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   884
    nr <= 255 ifTrue:[
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   885
	codeStream
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   886
	    nextPut:#lineno;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   887
	    nextPut:nr.
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   888
    ] ifFalse:[
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   889
	nr <= 16rFFFF ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   890
	    codeStream
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   891
		nextPut:#lineno16;
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   892
		nextPutInt16:nr MSB:true.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   893
	]
601
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   894
    ].
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   895
!
74a414960773 class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 600
diff changeset
   896
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   897
contextMustBeReturnable
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   898
    ^ false
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   899
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   900
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   901
correctedSource
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   902
    ^ nil
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   903
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   904
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   905
createMethod
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   906
    |newMethod|
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   907
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   908
    newMethod := self methodClass new:(litArray size).
127
b8c5bff0f6d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
   909
    newMethod mclass:classToCompileFor.
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   910
    litArray notNil ifTrue:[
860
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   911
	"/ fixup CheapBlocks method-field in literal array,
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   912
	litArray do:[:aLiteral |
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   913
	    (aLiteral isMemberOf:CheapBlock) ifTrue:[
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   914
		aLiteral setMethod:newMethod.
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   915
	    ]
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   916
	].
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   917
	newMethod literals:litArray
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   918
    ].
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   919
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   920
    newMethod numberOfVars:(self numberOfMethodVars + (maxNumTemp ? 0)).
860
2aae8a392d3e class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 859
diff changeset
   921
    newMethod numberOfArgs:(self numberOfMethodArgs).
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   922
    newMethod stackSize:(self maxStackDepth).
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   923
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   924
    ^ newMethod
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   925
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
   926
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   927
genByteCodeFrom:symbolicCodeArray
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   928
    "convert symbolicCode into bytecodes"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   929
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   930
    |symIndex    "{Class: SmallInteger }"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   931
     codeSize    "{Class: SmallInteger }"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   932
     symCodeSize "{Class: SmallInteger }"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   933
     index nextSym addr
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   934
     codeSymbol nargs needRetry
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   935
     stackDepth relocInfo level nvars round
443
3cf2daeb00c8 changed: #genByteCodeFrom:
Claus Gittinger <cg@exept.de>
parents: 396
diff changeset
   936
     lnoLO lnoHI |
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   937
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   938
    symbolicCodeArray isNil ifTrue:[^ self].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   939
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   940
    round := 0.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   941
    needRetry := true.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   942
    symCodeSize := symbolicCodeArray size.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   943
    codeSize := symCodeSize.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   944
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   945
    [needRetry] whileTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   946
	stackDepth := 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   947
	maxStackDepth := 0.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   948
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   949
	codeBytes := ByteArray uninitializedNew:codeSize.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   950
	relocInfo := Array basicNew:(codeSize + 1).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   951
	symIndex := 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   952
	codeIndex := 1.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   953
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   954
	needRetry := false.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   955
	round := round + 1.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   956
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   957
	[symIndex <= symCodeSize] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   958
	    relocInfo at:symIndex put:codeIndex.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   959
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   960
	    codeSymbol := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   961
	    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   962
	    stackDelta := 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   963
	    extra := extraLiteral := nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   964
	    lineno := false.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   965
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   966
	    self appendByteCodeFor:codeSymbol.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   967
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   968
	    extraLiteral notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   969
		self addLiteral:extraLiteral
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   970
	    ].
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   971
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   972
	    lineno ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   973
		lnoLO := (symbolicCodeArray at:symIndex) ? 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   974
		self appendByte:(lnoLO min:255).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   975
		symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   976
		codeSymbol == #lineno16 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   977
		    lnoHI := (symbolicCodeArray at:symIndex) ? 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   978
		    self appendByte:(lnoHI min:255).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   979
		    symIndex := symIndex + 1
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   980
		]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   981
	    ].
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   982
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   983
	    extra notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   984
		nextSym := symbolicCodeArray at:symIndex.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   985
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   986
		(extra == #number) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   987
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   988
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   989
		    self appendSignedByte:index
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   990
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   991
		] ifFalse:[ (extra == #number16) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   992
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   993
		    symIndex := symIndex + 2.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   994
		    self appendSignedWord:index
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
   995
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   996
		] ifFalse:[ (extra == #unsigned16) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   997
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   998
		    symIndex := symIndex + 2.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   999
		    self appendWord:index
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1000
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1001
		] ifFalse:[ (extra == #index) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1002
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1003
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1004
		    self appendByte:index
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1005
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1006
		] ifFalse:[ (extra == #lit) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1007
		    index := self addLiteral:nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1008
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1009
		    self appendByte:index
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1010
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1011
		] ifFalse:[ (extra == #speciallit) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1012
		    index := self addLiteral:nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1013
		    index > 255 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1014
			self parseError:'too many globals (' ,
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1015
					(symbolicCodeArray at:symIndex) ,
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1016
					' index=' , index printString ,
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1017
					') in method - please simplify'.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1018
			^ #Error
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1019
		    ].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1020
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1021
		    self appendByte:index.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1022
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1023
		] ifFalse:[ (extra == #speciallitS) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1024
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1025
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1026
		    self appendByte:index.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1027
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1028
		] ifFalse:[ (extra == #speciallitL) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1029
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1030
		    symIndex := symIndex + 2.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1031
		    self appendWord:index.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1032
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1033
		] ifFalse:[ (extra == #offset) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1034
		    relocInfo at:symIndex put:codeIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1035
		    self addReloc:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1036
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1037
		    self appendByte:0
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1038
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1039
		] ifFalse:[ (extra == #indexLevel) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1040
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1041
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1042
		    self appendByte:index.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1043
		    level := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1044
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1045
		    self appendByte:level
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1046
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1047
		] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1048
		    relocInfo at:symIndex put:codeIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1049
		    self addReloc:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1050
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1051
		    self appendEmptyByte.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1052
		    nvars := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1053
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1054
		    self appendByte:nvars.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1055
		    level := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1056
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1057
		    self appendByte:level
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1058
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1059
		] ifFalse:[ (extra == #absoffset) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1060
		    relocInfo at:symIndex put:codeIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1061
		    self addReloc:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1062
		    addr := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1063
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1064
		    self appendByte:(addr bitAnd:16rFF).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1065
		    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1066
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1067
		] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1068
		    relocInfo at:symIndex put:codeIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1069
		    self addReloc:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1070
		    addr := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1071
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1072
		    self appendByte:(addr bitAnd:16rFF).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1073
		    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1074
		    nvars := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1075
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1076
		    self appendByte:nvars.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1077
		    level := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1078
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1079
		    self appendByte:level
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1080
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1081
		] ifFalse:[ (extra == #special) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1082
		    ((codeSymbol == #send)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1083
		     or:[codeSymbol == #sendSelf
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1084
		     or:[codeSymbol == #superSend
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1085
		     or:[codeSymbol == #hereSend]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1086
			index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1087
			symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1088
			nargs := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1089
			symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1090
			self appendByte:nargs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1091
			self appendByte:index.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1092
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1093
			(codeSymbol == #superSend
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1094
			or:[codeSymbol == #hereSend]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1095
			    index := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1096
			    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1097
			    self appendByte:index
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1098
			].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1099
			stackDelta := nargs negated.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1100
			codeSymbol == #sendSelf ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1101
			    stackDelta := stackDelta + 1
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1102
			]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1103
		    ] ifFalse:[ (codeSymbol == #sendDrop) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1104
			index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1105
			symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1106
			nargs := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1107
			symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1108
			self appendByte:nargs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1109
			self appendByte:index.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1110
			stackDelta := (nargs + 1) negated
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1111
		    ]]
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1112
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1113
		] ifFalse:[ (extra == #specialL) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1114
		    ((codeSymbol == #sendL)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1115
		     or:[codeSymbol == #sendDropL
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1116
		     or:[codeSymbol == #sendSelfL
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1117
		     or:[codeSymbol == #superSendL
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1118
		     or:[codeSymbol == #hereSendL]]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1119
			index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1120
			symIndex := symIndex + 2.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1121
			nargs := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1122
			symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1123
			self appendByte:nargs.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1124
			self appendWord:index.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1125
			(codeSymbol == #superSendL
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1126
			or:[codeSymbol == #hereSendL]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1127
			    index := symbolicCodeArray at:symIndex.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1128
			    symIndex := symIndex + 2.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1129
			    self appendWord:index.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1130
			].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1131
			stackDelta := nargs negated.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1132
			codeSymbol == #sendSelfL ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1133
			    stackDelta := stackDelta + 1
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1134
			]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1135
		    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1136
		] ifFalse:[ (extra == #specialSend) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1137
		    index := nextSym.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1138
		    symIndex := symIndex + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1139
		    self appendByte:index.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1140
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1141
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1142
		    "/ self halt:'internal error'
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1143
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1144
		]]]]]]]]]]]]]]]]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1145
	    ].
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1146
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1147
	    stackDepth := stackDepth + stackDelta.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1148
	    (stackDepth > maxStackDepth) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1149
		maxStackDepth := stackDepth
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1150
	    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1151
	].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1152
	relocInfo at:symIndex put:codeIndex.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1153
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1154
	needRetry ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1155
	    "
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1156
	     now relocate - returns true if ok, false if we have to do it again
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1157
	     (when short jumps have been changed to long jumps)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1158
	    "
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1159
	    relocList notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1160
		needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1161
		"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1162
		 if returned with false, a relative jump was made into
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1163
		 an absolute jump - need to start over with one more byte space
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1164
		"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1165
		needRetry ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1166
		    relocList := nil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1167
		    codeSize := codeSize + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1168
		]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1169
	    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1170
	] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1171
	    'Compiler [info]: compiling again ...' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1172
	]
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1173
    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1174
    "code printNL."
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1175
    ^ errorFlag
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1176
443
3cf2daeb00c8 changed: #genByteCodeFrom:
Claus Gittinger <cg@exept.de>
parents: 396
diff changeset
  1177
    "Modified: / 03-09-1995 / 12:59:43 / claus"
3cf2daeb00c8 changed: #genByteCodeFrom:
Claus Gittinger <cg@exept.de>
parents: 396
diff changeset
  1178
    "Modified: / 19-05-2010 / 12:55:53 / cg"
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1179
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1180
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1181
genSymbolicCode
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1182
    "traverse the parse-tree producing symbolicCode - return the codeArray"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1183
754
c45c54b7fdcd class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 748
diff changeset
  1184
    |codeStream code lastStatement|
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1185
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1186
    litArray := nil.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1187
    codeStream := WriteStream on:(OrderedCollection new:100).
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1188
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1189
"/    primitiveContextInfo notNil ifTrue:[
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1190
"/        (primitiveContextInfo includes:('exception:' -> #unwind)) ifTrue:[
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1191
"/            self genSpecialStatement:#markForUnwind on:codeStream
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1192
"/        ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1193
"/        (primitiveContextInfo includes:('exception:' -> #handle)) ifTrue:[
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1194
"/            self genSpecialStatement:#markForHandle on:codeStream
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1195
"/        ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1196
"/        (primitiveContextInfo includes:('exception:' -> #raise)) ifTrue:[
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1197
"/            self genSpecialStatement:#markForRaise on:codeStream
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1198
"/        ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1199
"/    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1200
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
  1201
    tree codeVariableSetupOn:codeStream for:self.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1202
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1203
    (tree statements ? #()) do:[:thisStatement |
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1204
	lastStatement := thisStatement.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1205
	thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1206
    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1207
    (lastStatement isNil or:[lastStatement isReturnNode not])
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1208
    ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1209
	"not a return - add retNil"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1210
	"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1211
	 if the last statement was a send for side-effect,
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1212
	 replace the previous drop by a retNil.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1213
	 In this case we have to keep an extra retNil because
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1214
	 it could be a jump target.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1215
	"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1216
	(lastStatement notNil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1217
	 and:[(code := codeStream contents) notNil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1218
	 and:[code size > 0
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1219
	 and:[code last == #drop]]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1220
	    codeStream backStep.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1221
	    codeStream nextPut:#retNil
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1222
	].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1223
	codeStream nextPut:#retNil
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1224
    ].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1225
    ^ codeStream contents
239
8db5212859c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1226
8db5212859c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1227
    "Modified: / 21-02-2007 / 12:30:44 / cg"
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1228
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1229
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1230
generateVariables:varCollection on:codeStream
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1231
    varCollection isNil ifTrue:[^ self].
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1232
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1233
    varCollection do:[:eachVar |
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1234
	"/ generate code to set it up.
51
611e32ab2648 more compilation
Claus Gittinger <cg@exept.de>
parents: 50
diff changeset
  1235
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1236
	|initExpression setupExpr|
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1237
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1238
	initExpression := eachVar expressionForSetup.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1239
	initExpression notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1240
	    setupExpr := AssignmentNode
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1241
			    variable:(self nodeForMethodVariable:eachVar name)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1242
			    expression:initExpression.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1243
	    setupExpr codeForSideEffectOn:codeStream inBlock:nil for:self.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1244
	]
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1245
    ]
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1246
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1247
209
e8630d605170 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
  1248
isBuiltInSelector:sel forReceiver:receiver
61
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
  1249
    ^ false
a2c7cd9b17b3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 58
diff changeset
  1250
209
e8630d605170 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
  1251
    "Created: / 10-08-2006 / 12:09:56 / cg"
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1252
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1253
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1254
maxStackDepth
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1255
     ^ maxNumTemp ? 0
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1256
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1257
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1258
methodClass
608
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  1259
     ^ methodClass ? JavaScriptFunction
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  1260
f9650ab2fae5 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  1261
    "Modified: / 22-07-2013 / 15:52:58 / cg"
38
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1262
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1263
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1264
numberOfMethodArgs
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1265
     ^ tree _argVariables size.
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1266
!
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1267
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1268
numberOfMethodVars
d055d9ff4b71 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 37
diff changeset
  1269
     ^ tree _localVariables size.
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1270
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1271
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1272
relocateWith:symbolicCodeArray relocInfo:relocInfo
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1273
    "helper for genByteCodeFrom - relocate code using relocInfo.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1274
     if relocation fails badly (due to long relative jumps) patch
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1275
     symbolicCode to use absolute jumps instead and return false
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1276
     (genByteCodeFrom will then try again). Otherwise return true.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1277
     Also, on the fly, jumps to jumps and jumps to return are handled."
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1278
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1279
    |delta       "{Class: SmallInteger }"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1280
     codePos     "{Class: SmallInteger }"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1281
     opCodePos   "{Class: SmallInteger }"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1282
     codeOffset  "{Class: SmallInteger }"
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1283
     symOffset
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1284
     opcode      "{Class: SmallInteger }"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1285
     dstOpcode jumpTarget
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1286
     jumpCode deleteSet|
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1287
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1288
    deleteSet := OrderedCollection new.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1289
    relocList do:[:sIndex |
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1290
	"have to relocate symCode at sIndex ..."
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1291
	symOffset := symbolicCodeArray at:sIndex.   "the target in the symbolic code"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1292
	codePos := relocInfo at:sIndex.             "position of the offet in byte code"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1293
	codeOffset := relocInfo at:symOffset.       "position of the target in byte code"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1294
	delta := codeOffset - codePos - 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1295
	opCodePos := codePos - 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1296
	opcode := codeBytes at:opCodePos.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1297
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1298
	(opcode between:190 and:199) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1299
	    "an absolute jump/makeBlock"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1300
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1301
	    codeBytes at:codePos put:(codeOffset bitAnd:16rFF).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1302
	    codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1303
	] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1304
	    "get jump-code from long and vlong codes"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1305
	    (opcode between:50 and:59) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1306
		(opcode between:60 and:69) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1307
		    opcode := opcode - 10
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1308
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1309
		    (opcode between:70 and:79) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1310
			opcode := opcode - 20
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1311
		    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1312
			self error:'invalid code to relocate'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1313
		    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1314
		].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1315
	    ].
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1316
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1317
	    "optimize jump to return and jump to jump"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1318
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1319
	    (opcode == 54) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1320
		"a jump"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1321
		dstOpcode := symbolicCodeArray at:symOffset.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1322
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1323
		(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1324
		    "a jump to a return - put in the return instead jump"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1325
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1326
		    symbolicCodeArray at:(sIndex - 1) put:dstOpcode.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1327
		    symbolicCodeArray at:sIndex put:dstOpcode.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1328
		    codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1329
		    delta := 0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1330
		    deleteSet add:sIndex.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1331
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1332
"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1333
'jump to return at: ' print. (sIndex - 1) printNL.
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1334
"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1335
		] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1336
		    (dstOpcode == #jump) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1337
			"jump to jump to be done soon"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1338
			jumpTarget := symbolicCodeArray at:(symOffset + 1).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1339
"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1340
'jump to jump at: ' print. (sIndex - 1) print.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1341
'  newTarget:' print. jumpTarget printNL.
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1342
"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1343
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1344
			symbolicCodeArray at:sIndex put:jumpTarget.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1345
			symOffset := jumpTarget.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1346
			codeOffset := relocInfo at:symOffset.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1347
			delta := codeOffset - codePos - 1.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1348
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1349
			"continue with new delta"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1350
		    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1351
		]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1352
	    ].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1353
	    (#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1354
		"a conditional jump"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1355
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1356
		dstOpcode := symbolicCodeArray at:symOffset.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1357
		(dstOpcode == #jump) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1358
		    "conditional jump to unconditional jump"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1359
		    jumpTarget := symbolicCodeArray at:(symOffset + 1).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1360
"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1361
'cond jump to jump at: ' print. (sIndex - 1) print.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1362
'  newTarget:' print. jumpTarget printNL.
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1363
"
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1364
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1365
		    symbolicCodeArray at:sIndex put:jumpTarget.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1366
		    symOffset := jumpTarget.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1367
		    codeOffset := relocInfo at:symOffset.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1368
		    delta := codeOffset - codePos - 1.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1369
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1370
		    "continue with new delta"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1371
		].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1372
	    ].
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1373
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1374
	    (delta >= 0) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1375
		(delta > 127) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1376
		    (opcode between:50 and:59) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1377
			self error:'invalid code to relocate'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1378
		    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1379
			(delta > 255) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1380
			    "change jmp into vljmp ..."
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1381
			    codeBytes at:opCodePos put:(opcode + 20).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1382
			    delta := delta - 256
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1383
			] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1384
			    "change jmp into ljmp ..."
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1385
			    codeBytes at:opCodePos put:(opcode + 10).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1386
			    delta := delta - 128
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1387
			].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1388
			(delta > 127) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1389
			    "change symbolic into a jump absolute and fail"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1390
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1391
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1392
			    symbolicCodeArray at:sIndex put:symOffset.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1393
"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1394
'change short into abs jump' printNL.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1395
"
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1396
			    deleteSet do:[:d | relocList remove:d].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1397
			    ^ false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1398
			]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1399
		    ].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1400
		].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1401
		codeBytes at:codePos put:delta
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1402
	    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1403
		(delta < -128) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1404
		    (opcode between:50 and:59) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1405
			self error:'invalid code to relocate'
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1406
		    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1407
			(delta < -256) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1408
			    "change jmp into vljmp ..."
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1409
			    codeBytes at:opCodePos put:(opcode + 20).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1410
			    delta := delta + 256
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1411
			] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1412
			    "change jmp into ljmp ..."
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1413
			    codeBytes at:opCodePos put:(opcode + 10).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1414
			    delta := delta + 128
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1415
			].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1416
			(delta < -128) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1417
			    "change symbolic into a jump absolute and fail"
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1418
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1419
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1420
			    symbolicCodeArray at:sIndex put:symOffset.
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1421
"
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1422
'change short into abs jump' printNL.
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1423
"
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1424
			    deleteSet do:[:d | relocList remove:d].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1425
			    ^ false
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1426
			]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1427
		    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1428
		].
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1429
		codeBytes at:codePos put:(256 + delta)
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1430
	    ]
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1431
	]
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1432
    ].
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1433
    (errorFlag == #Error) ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1434
	self error:'relocation range error'
50
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1435
    ].
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1436
    ^ true
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1437
!
c2e42f087322 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 49
diff changeset
  1438
49
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1439
specialGlobalCodeFor:aSymbol
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1440
    ^ nil.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1441
!
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1442
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1443
specialSendCodeFor:sel
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1444
    "return the codeExtension for sends,
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1445
     which can be performed by specialSend opCode"
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1446
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1447
    ^ nil.
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1448
da82b821e14c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 47
diff changeset
  1449
    "Modified: 4.6.1997 / 12:31:08 / cg"
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
! !
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1452
!JavaScriptCompiler methodsFor:'compiling'!
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1453
509
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  1454
compile:aString forClass:aClass inCategory:cat
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1455
    "compile from source code"
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1456
    ^ self
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1457
	compile:aString
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1458
	forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1459
	inCategory:cat
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1460
	notifying:nil
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1461
	install:true
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1462
	skipIfSame:false
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1463
	silent:false
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1464
	foldConstants:true
509
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  1465
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  1466
    "Created: / 30-09-2011 / 12:49:45 / cg"
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1467
    "Modified (comment): / 08-02-2019 / 11:26:00 / Claus Gittinger"
509
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  1468
!
2f9173d9bbe4 added: #compile:forClass:inCategory:
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  1469
248
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1470
compile:aString forClass:aClass inCategory:cat notifying:requestorArg
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1471
		 install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1472
    "compile from source code"
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1473
    ^ self
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1474
	compile:aString forClass:aClass inCategory:cat notifying:requestorArg
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1475
	install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1476
	ifFail:[]
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1477
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1478
    "Modified: / 22-07-2013 / 16:07:23 / cg"
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1479
    "Modified (comment): / 08-02-2019 / 11:25:56 / Claus Gittinger"
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1480
!
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1481
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1482
compile:sourceCodeString forClass:aClass inCategory:cat notifying:aRequestor
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1483
                install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1484
                ifFail:failBlock
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1485
    "compile from source code"
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1486
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1487
    |parseTree errMsg definedFunctionNames|
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1488
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1489
    self setClassToCompileFor:aClass.
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1490
    self parseForCode.
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1491
    "/    fold ifFalse:[self foldConstants:nil].
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1492
    self notifying:requestor.
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1493
    self source:sourceCodeString.
462
7062e98dd382 changed: #compile:forClass:inCategory:notifying:install:skipIfSame:silent:foldConstants:
Claus Gittinger <cg@exept.de>
parents: 460
diff changeset
  1494
    self nextToken.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1495
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1496
    "/ the old code caught errors and returned #Error
248
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1497
    "/ we now migrate towards letting the caller know about the exception.
582
2a334445270f class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
  1498
"/    ParseError handle:[:ex |
248
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1499
"/        Transcript showCR:'JS translation error: ' , ex description "errorMessage".
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1500
"/        ^ #Error
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1501
"/    ] do:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1502
809
9edf22554afa class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
  1503
    (tokenType == #Identifier and:[tokenName = 'static']) ifTrue:[
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1504
        self nextToken.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1505
        self setClassToCompileFor:aClass theMetaclass.
809
9edf22554afa class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
  1506
    ].
9edf22554afa class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 808
diff changeset
  1507
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1508
        parseTree := self function.
248
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1509
"/    ].
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1510
857
7933834a28d8 class: JavaScriptCompiler
ca
parents: 837
diff changeset
  1511
    tokenType == $; "16r3B" ifTrue:[
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1512
        self nextToken.
857
7933834a28d8 class: JavaScriptCompiler
ca
parents: 837
diff changeset
  1513
    ].
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1514
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1515
    "/ multiple functions?
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1516
    [tokenType ~~ #EOF
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1517
      and:[ parseTree notNil
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1518
      and:[ parseTree isFunctionNode
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1519
    ]]] whileTrue:[
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1520
        definedFunctionNames isNil ifTrue:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1521
            definedFunctionNames := Set new.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1522
        ].
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1523
        (definedFunctionNames includes:parseTree functionName) ifTrue:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1524
            self notifyError:('redefinition of function "%1"' bindWith:parseTree functionName)
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1525
                 position:(parseTree startPosition) to:(parseTree endPosition)
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1526
                 lineNr:(parseTree lineNumber)
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1527
        ].
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1528
        definedFunctionNames add:parseTree functionName.
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1529
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1530
        self
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1531
            compileTree:parseTree
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1532
            source:sourceCodeString
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1533
            forClass:classToCompileFor
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1534
            inCategory:cat notifying:requestor
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1535
            install:true skipIfSame:skipIfSame silent:silent foldConstants:fold
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1536
            ifFail:failBlock.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1537
        parseTree := self function.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1538
        tokenType == $; ifTrue:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1539
            self nextToken
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1540
        ].
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1541
    ].
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1542
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1543
    tokenType ~~ #EOF ifTrue:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1544
        tokenType == $} ifTrue:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1545
            errMsg := 'unexpected "}" at end of function'.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1546
        ] ifFalse:[
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1547
            errMsg := 'unexpected garbage at end of function'.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1548
        ].
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1549
        self notifyError:errMsg position:tokenPosition to:source position
837
778b36c8bc3b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 818
diff changeset
  1550
    ].
778b36c8bc3b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 818
diff changeset
  1551
248
affa4a284d61 error raising
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1552
    parseTree isNil ifTrue:[
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1553
        ParseError raiseRequestErrorString:'empty function'.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1554
        "/ Transcript showCR:'JS translation error'.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1555
        failBlock value.
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1556
        ^ #Error
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1557
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1558
    ^ self
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1559
        compileTree:parseTree
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1560
        source:sourceCodeString
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1561
        forClass:classToCompileFor
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1562
        inCategory:cat notifying:requestor
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1563
        install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1564
        ifFail:failBlock
239
8db5212859c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1565
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1566
    "Created: / 22-07-2013 / 16:05:41 / cg"
1058
c59b68af81a5 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1567
    "Modified: / 08-02-2019 / 12:44:24 / Claus Gittinger"
1227
3210fc572401 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 1118
diff changeset
  1568
    "Modified: / 30-01-2020 / 12:45:24 / Stefan Vogel"
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1569
!
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1570
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1571
compileTree:tree source:sourceString forClass:aClass inCategory:cat notifying:requestor
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1572
		 install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1573
    "compile from a parsetree"
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1574
    ^ self
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1575
	compileTree:tree
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1576
	source:sourceString forClass:aClass inCategory:cat notifying:requestor
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1577
	install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1578
	ifFail:[]
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1579
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1580
    "Modified: / 22-07-2013 / 16:06:58 / cg"
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1581
    "Modified (comment): / 08-02-2019 / 11:25:33 / Claus Gittinger"
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1582
!
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1583
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1584
compileTree:tree source:sourceString forClass:aClass inCategory:cat notifying:requestor
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1585
                 install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1586
                 ifFail:failBlock
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1587
    "compile from a parsetree"
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1588
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1589
    |sel newMethod newSource pkg symbolicCodeArray fn|
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1590
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1591
    self setClassToCompileFor:aClass.
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1592
    self parseForCode.
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1593
    fold ifFalse:[self foldConstants:nil].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1594
    self notifying:requestor.
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1595
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1596
    tree isNil ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1597
        Transcript showCR:'JS translation error'.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1598
        failBlock value.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1599
        ^ #Error
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1600
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1601
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1602
    self tree:tree.
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1603
    fn := tree functionName ? 'unimplementedFunction'.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1604
    sel := self class selectorFor:fn numArgs:self numberOfMethodArgs.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1605
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1606
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1607
     produce symbolic code first
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1608
    "
582
2a334445270f class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 519
diff changeset
  1609
    ParseError handle:[:ex |
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1610
        ex reject.
460
b18bba05f8a9 changed: #fileOutAllDefinitionsOn:
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  1611
"/ self halt.
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1612
        Transcript showCR:'JS translation error: ' , ex errorMessage.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1613
        failBlock value.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1614
        ^ #Error
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1615
    ] do:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1616
        symbolicCodeArray := self genSymbolicCode.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1617
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1618
    (symbolicCodeArray == #Error) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1619
        Transcript show:'    '.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1620
        sel notNil ifTrue:[
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1621
            Transcript show:(sel ,' ')
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1622
        ].
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1623
        Transcript showCR:'JS translation error'.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1624
        failBlock value.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1625
        ^ #Error
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1626
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1627
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1628
    "
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1629
     take this, producing bytecode
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1630
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1631
    ((self genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1632
        Transcript show:'    '.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1633
        sel notNil ifTrue:[
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1634
            Transcript show:(sel ,' ')
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1635
        ].
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1636
        Transcript showCR:'relocation error - must be simplified'.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1637
        failBlock value.
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1638
        ^ #Error
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1639
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1640
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1641
     finally create the new method-object
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1642
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1643
    newMethod := self createMethod.
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1644
    newMethod byteCode:(self code).
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1645
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1646
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1647
     if there where any corrections, install the updated source
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1648
    "
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1649
    (newSource := self correctedSource) notNil ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1650
        newMethod source:newSource string
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1651
    ] ifFalse:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1652
        newMethod source:sourceString string.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1653
    ].
111
4f6b85a07644 *** empty log message ***
penk
parents: 94
diff changeset
  1654
4f6b85a07644 *** empty log message ***
penk
parents: 94
diff changeset
  1655
    newMethod mclass:aClass.
4f6b85a07644 *** empty log message ***
penk
parents: 94
diff changeset
  1656
    newMethod setCategory:cat.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1657
    (aClass isNil or:[aClass owningClass isNil]) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1658
        pkg := Class packageQuerySignal query.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1659
    ] ifFalse:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1660
        pkg := aClass owningClass package
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1661
    ].
111
4f6b85a07644 *** empty log message ***
penk
parents: 94
diff changeset
  1662
    newMethod setPackage:pkg.
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1663
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1664
    (self contextMustBeReturnable) ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1665
        newMethod contextMustBeReturnable:true
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1666
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1667
    install ifTrue:[
1118
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1668
        aClass notNil ifTrue:[
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1669
            aClass addSelector:sel withMethod:newMethod
948b84ffe2dd #BUGFIX by exept
Claus Gittinger <cg@exept.de>
parents: 1095
diff changeset
  1670
        ]
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1671
    ].
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1672
94
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1673
"/    silent ifFalse:[
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1674
"/        aClass isNil ifTrue:[
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1675
"/            Transcript showCR:('    compiled: <nil> ', sel)
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1676
"/        ] ifFalse:[
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1677
"/            Transcript showCR:('    compiled: ', aClass name,' ', sel)
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1678
"/        ]
712e02f77a4c *** empty log message ***
ca
parents: 93
diff changeset
  1679
"/    ].
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1680
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1681
    ^ newMethod
239
8db5212859c6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
  1682
633
d457f4b9cb55 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
  1683
    "Created: / 22-07-2013 / 16:06:29 / cg"
1055
e5743c89bbc2 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1031
diff changeset
  1684
    "Modified (comment): / 08-02-2019 / 11:25:27 / Claus Gittinger"
86
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1685
! !
0f57fe8b7708 *** empty log message ***
ca
parents: 79
diff changeset
  1686
808
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1687
!JavaScriptCompiler methodsFor:'initialization'!
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1688
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1689
reset
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1690
    "needed between functions, when reading multiple functions"
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1691
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1692
    usesSuper := false.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1693
    gotAnyRealStatement := false.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1694
    staticVars := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1695
    moreSharedPools := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1696
    modifiedVars := modifiedGlobals := modifiedInstVars := modifiedClassVars := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1697
    usedVars := usedGlobals := usedInstVars := usedClassVars := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1698
    currentEnvironment := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1699
    inArrayLiteral := false.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1700
    collectedSource := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1701
    currentComments := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1702
    errorFlag := false.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1703
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1704
    relocList := codeBytes := litArray := stackDelta := extraLiteral := maxStackDepth := nil.
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1705
    methodTempVars := maxNumTemp := loopStack := nil.
813
10b816839405 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  1706
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1707
    tokenPosition := outCol := 1.
813
10b816839405 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 809
diff changeset
  1708
    tokenLineNr := lineNr := 1.
808
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1709
! !
fc9d66f73b5b class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
  1710
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1711
!JavaScriptCompiler methodsFor:'loops'!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1712
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1713
loopDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1714
    loopStack isNil ifTrue:[^ nil].
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1715
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1716
    ^ loopStack last
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1717
!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1718
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1719
newLoopDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1720
    ^ LoopDescription new
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1721
!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1722
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1723
newLoopDescriptionForBlock
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1724
    ^ LoopDescriptionForBlock new
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1725
!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1726
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1727
newSwitchDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1728
    ^ SwitchDescription new
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1729
!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1730
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1731
popLoopDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1732
    ^ loopStack removeFirst
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1733
!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1734
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1735
pushLoopDescription:aDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1736
    loopStack isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1737
	loopStack := OrderedCollection new.
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1738
    ].
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1739
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1740
    loopStack addFirst:aDescription
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1741
! !
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1742
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1743
!JavaScriptCompiler methodsFor:'parsing'!
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1744
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1745
compileFunctionDefinitions
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1746
    |classToCompileForBefore|
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1747
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1748
    classToCompileForBefore := classToCompileFor.
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1749
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1750
    [ tokenType ~~ #EOF ] whileTrue:[
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1751
	|cat mthd sourceString|
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1752
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1753
	outStream := WriteStream on:(String new:100).
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1754
	"/ because the first token ('function') has already been read,
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1755
	"/ we have to manually shift it into the source collecting stream (sigh)
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1756
	outStream nextPutAll:self token.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1757
	self reset.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1758
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1759
	classToCompileFor := classToCompileForBefore.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1760
	tree := self functionOrStaticFunction:false.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1761
	cat := self methodCategory.
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1762
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1763
	"/ the collected source of this function
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1764
	sourceString := outStream contents.
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1765
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1766
	mthd := self
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1767
		    compileTree:tree source:sourceString
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1768
		    forClass:classToCompileFor inCategory:(cat ? 'no category')
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1769
		    notifying:nil
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1770
		    install:true
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1771
		    skipIfSame:false
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1772
		    silent:false
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1773
		    foldConstants:true.
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1774
1059
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1775
	token = $} ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1776
	    self nextToken.
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1777
	].
922
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1778
    ]
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1779
! !
554ed231f685 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 900
diff changeset
  1780
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1781
!JavaScriptCompiler::LoopDescription methodsFor:'accessing'!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1782
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1783
breakLabel
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1784
    "return the value of the instance variable 'breakLabel' (automatically generated)"
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1785
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1786
    ^ breakLabel
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1787
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1788
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1789
breakLabel:something
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1790
    "set the value of the instance variable 'breakLabel' (automatically generated)"
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1791
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1792
    breakLabel := something.
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1793
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1794
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1795
continueLabel
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1796
    "return the value of the instance variable 'continueLabel' (automatically generated)"
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1797
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1798
    ^ continueLabel
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1799
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1800
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1801
continueLabel:something
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1802
    "set the value of the instance variable 'continueLabel' (automatically generated)"
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1803
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1804
    continueLabel := something.
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1805
! !
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1806
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1807
!JavaScriptCompiler::LoopDescription methodsFor:'backpatching'!
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1808
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1809
patchBreaksTo:breakPosition in:codeStream
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1810
    |code|
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1811
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1812
    backPatchListForBreak isEmptyOrNil ifTrue:[^ self].
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1813
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1814
    code := codeStream contents.
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1815
    backPatchListForBreak do:[:eachPatchPos |
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1816
	code at:eachPatchPos put:breakPosition
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1817
    ].
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1818
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1819
77
4b3aafeb206f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
  1820
patchContinuesTo:continuePosition in:codeStream
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1821
    |code|
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1822
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1823
    backPatchListForContinue isEmptyOrNil ifTrue:[^ self].
77
4b3aafeb206f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
  1824
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1825
    code := codeStream contents.
77
4b3aafeb206f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 73
diff changeset
  1826
    backPatchListForContinue do:[:eachPatchPos |
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1827
	code at:eachPatchPos put:continuePosition
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1828
    ].
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1829
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1830
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1831
rememberToBackPatchForBreak:position
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1832
    backPatchListForBreak isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1833
	backPatchListForBreak := OrderedCollection new
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1834
    ].
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1835
    backPatchListForBreak add:position
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1836
!
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1837
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1838
rememberToBackPatchForContinue:position
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1839
    backPatchListForContinue isNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1840
	backPatchListForContinue := OrderedCollection new
73
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1841
    ].
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1842
    backPatchListForContinue add:position
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1843
! !
2db8d80075e1 break & continue
Claus Gittinger <cg@exept.de>
parents: 61
diff changeset
  1844
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1845
!JavaScriptCompiler::LoopDescription methodsFor:'code generation'!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1846
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1847
codeForBreakOn:aStream at:lineNr for:aCompiler
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1848
    |jmpDeltaPos|
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1849
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1850
    breakLabel notNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1851
	aStream nextPut:#jump.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1852
	aStream nextPut:breakLabel.
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1853
    ] ifFalse:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1854
	aStream nextPut:#jump.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1855
	jmpDeltaPos := aStream position + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1856
	aStream nextPut:0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1857
	self rememberToBackPatchForBreak:jmpDeltaPos.
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1858
    ].
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1859
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1860
    "Created: / 06-11-2013 / 21:18:36 / cg"
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1861
!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1862
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1863
codeForContinueOn:aStream at:lineNr for:aCompiler
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1864
    |jmpDeltaPos|
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1865
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1866
    continueLabel notNil ifTrue:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1867
	aStream nextPut:#jump.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1868
	aStream nextPut:continueLabel.
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1869
    ] ifFalse:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1870
	aStream nextPut:#jump.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1871
	jmpDeltaPos := aStream position + 1.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1872
	aStream nextPut:0.
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1873
	self rememberToBackPatchForContinue:jmpDeltaPos.
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1874
    ].
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1875
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1876
    "Created: / 06-11-2013 / 21:19:27 / cg"
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1877
! !
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1878
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1879
!JavaScriptCompiler::LoopDescription methodsFor:'queries'!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1880
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1881
isLoop
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1882
    ^ true
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1883
! !
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1884
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1885
!JavaScriptCompiler::LoopDescriptionForBlock methodsFor:'accessing'!
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1886
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1887
deltaScope
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1888
    ^ deltaScope ? 1
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1889
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1890
    "Created: / 06-11-2013 / 20:34:51 / cg"
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1891
!
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1892
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1893
deltaScope:something
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1894
    deltaScope := something.
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1895
! !
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1896
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1897
!JavaScriptCompiler::LoopDescriptionForBlock methodsFor:'code generation'!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1898
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1899
codeForBreakOn:aStream at:lineNr for:aCompiler
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1900
    |thisContextVar node|
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1901
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1902
    thisContextVar := VariableNode type:#ThisContext name:#thisContext.
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1903
    node := MessageNode
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1904
		    receiver:thisContextVar
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1905
		    selector:#sender
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1906
		    args:#().
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1907
    node lineNumber:lineNr.
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1908
    self deltaScope timesRepeat:[
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1909
	node := MessageNode
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1910
			receiver:node
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1911
			selector:#sender
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1912
			args:#().
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1913
	node lineNumber:lineNr.
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1914
    ].
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1915
    node := MessageNode
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1916
		    receiver:node
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1917
		    selector:#return
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1918
		    args:#().
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1919
    node lineNumber:lineNr.
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1920
    node codeForSideEffectOn:aStream inBlock:nil for:aCompiler.
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1921
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1922
    "Created: / 06-11-2013 / 21:18:31 / cg"
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1923
!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1924
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1925
codeForContinueOn:aStream at:lineNr for:aCompiler
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1926
    |thisContextVar node|
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1927
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1928
    thisContextVar := VariableNode type:#ThisContext name:#thisContext.
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1929
    node := MessageNode
818
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1930
		    receiver:thisContextVar
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1931
		    selector:#return
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
  1932
		    args:#().
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1933
"/    node lineNumber:lineNr.
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1934
    node codeForSideEffectOn:aStream inBlock:nil for:aCompiler.
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1935
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1936
    "Created: / 06-11-2013 / 21:19:21 / cg"
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1937
! !
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1938
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1939
!JavaScriptCompiler::LoopDescriptionForBlock methodsFor:'queries'!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1940
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1941
isLoop
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1942
    ^ true
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1943
! !
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1944
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1945
!JavaScriptCompiler::SwitchDescription methodsFor:'backpatching'!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1946
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1947
rememberToBackPatchForContinue:position
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1948
    self error:'invalid continue in switch'
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1949
! !
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1950
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1951
!JavaScriptCompiler::SwitchDescription methodsFor:'code generation'!
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1952
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1953
codeForContinueOn:aStream at:lineNr for:aCompiler
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1954
    aCompiler parseError:'continue not within a loop (continue in switch not allowed)'.
726
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1955
1a4e669e0e58 class: JavaScriptCompiler
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
  1956
    "Created: / 06-11-2013 / 21:19:10 / cg"
719
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1957
! !
04275fd1cbdc class: JavaScriptCompiler
Stefan Vogel <sv@exept.de>
parents: 633
diff changeset
  1958
143
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1959
!JavaScriptCompiler::SwitchDescription methodsFor:'queries'!
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1960
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1961
isLoop
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1962
    ^ false
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1963
! !
8b9bf957b8ce switch; do..while
Claus Gittinger <cg@exept.de>
parents: 127
diff changeset
  1964
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1965
!JavaScriptCompiler class methodsFor:'documentation'!
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1967
version
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1968
    ^ '$Header$'
396
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
  1969
!
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
  1970
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
  1971
version_CVS
32265fb0a755 *** empty log message ***
fm
parents: 354
diff changeset
  1972
    ^ '$Header$'
37
761f72a40b6c initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1973
! !
1095
1571ca86cd46 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
  1974