ProgramNodeBuilder.st
author sr
Tue, 21 Feb 2017 16:54:14 +0100
branchexpecco_2_11_0
changeset 4129 c690dec12b7e
parent 2900 a1349983b2e7
child 4207 546b3e3e3df9
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
98
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
     3
	      All Rights Reserved
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    12
"{ Package: 'stx:libcomp' }"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    13
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    14
Object subclass:#ProgramNodeBuilder
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    15
	instanceVariableNames:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    16
	classVariableNames:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    17
	poolDictionaries:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    18
	category:'System-Compiler ST-80-compatibility'
98
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
claus
parents:
diff changeset
    21
!ProgramNodeBuilder class methodsFor:'documentation'!
claus
parents:
diff changeset
    22
claus
parents:
diff changeset
    23
copyright
claus
parents:
diff changeset
    24
"
claus
parents:
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
    26
	      All Rights Reserved
claus
parents:
diff changeset
    27
claus
parents:
diff changeset
    28
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    33
 hereby transferred.
claus
parents:
diff changeset
    34
"
claus
parents:
diff changeset
    35
!
claus
parents:
diff changeset
    36
claus
parents:
diff changeset
    37
documentation
claus
parents:
diff changeset
    38
"
claus
parents:
diff changeset
    39
    This is a pure mimicri class.
claus
parents:
diff changeset
    40
    It is not used by ST/X, but provided to support limited
claus
parents:
diff changeset
    41
    compatibility for applications which build up codetrees,
claus
parents:
diff changeset
    42
    knowing internals of ST-80's compiler class hierarchy.
claus
parents:
diff changeset
    43
    This classes protocol is not (not meant to be) fully covering
claus
parents:
diff changeset
    44
    the corresponding ST-80's classes protocol. It maps ST-80 messages
claus
parents:
diff changeset
    45
    to corresponding ST/X messages (as far as possible).
claus
parents:
diff changeset
    46
claus
parents:
diff changeset
    47
    NO WARRANTY and GUARANTEE; this class may be removed without notice.
claus
parents:
diff changeset
    48
"
claus
parents:
diff changeset
    49
! !
claus
parents:
diff changeset
    50
claus
parents:
diff changeset
    51
!ProgramNodeBuilder methodsFor:'tree building'!
claus
parents:
diff changeset
    52
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    53
newBlockBody:statements
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
    ^ (BlockNode arguments:#() home:nil variables:#()) statements:statements
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
    "Created: / 06-08-2006 / 23:25:36 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    58
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    59
newGlobal:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    60
    "return a treeNode for a global variable"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    62
    ^ VariableNode globalNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    63
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    64
    "Created: / 06-08-2006 / 01:37:56 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    65
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    66
98
claus
parents:
diff changeset
    67
newLiteralValue:aConstantValue
claus
parents:
diff changeset
    68
    "return a treeNode for a literal constant"
claus
parents:
diff changeset
    69
2900
a1349983b2e7 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 2117
diff changeset
    70
    aConstantValue isAssociation ifTrue:[
2117
eb138ea841a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1785
diff changeset
    71
        "/ happens when I am used by ST/80 or VW code, which assumes that a
eb138ea841a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1785
diff changeset
    72
        "/ global is stored as association (which it is not in ST/X)
eb138ea841a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1785
diff changeset
    73
        "/ check the caller and rewrite there.
eb138ea841a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1785
diff changeset
    74
        self halt:'incompatibility warning'
eb138ea841a8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1785
diff changeset
    75
    ].
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    76
98
claus
parents:
diff changeset
    77
    ^ ConstantNode value:aConstantValue
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    78
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    79
    "Modified: / 06-08-2006 / 15:16:04 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    80
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    81
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    82
newMessageReceiver: receiverNode selector: selector
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    83
    ^ self newMessageReceiver: receiverNode selector: selector arguments: #()
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    84
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    85
    "Created: / 06-08-2006 / 02:59:55 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    86
    "Modified: / 06-08-2006 / 13:29:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    87
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    88
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    89
newMessageReceiver: receiverNode selector: selector arguments: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    90
    selector isUnarySelector ifTrue:[
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    91
        self assert:(arguments isEmptyOrNil).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    92
        ^ UnaryNode receiver:receiverNode selector: selector args: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    93
    ].
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    94
    selector isBinarySelector ifTrue:[
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
        self assert:(arguments size == 1).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    96
        ^ BinaryNode receiver:receiverNode selector: selector args: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    97
    ].
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
    self assert:(arguments notEmptyOrNil).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
    ^ MessageNode receiver:receiverNode selector: selector args: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   100
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   101
    "Created: / 06-08-2006 / 03:02:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
    "Modified: / 06-08-2006 / 14:00:47 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   103
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   104
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
newMethodArgument:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   106
    "return a treeNode for a method arg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   107
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
    ^ VariableNode methodArgumentNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   109
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   110
    "Created: / 06-08-2006 / 01:15:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   111
    "Modified: / 06-08-2006 / 13:29:42 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   112
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   113
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   114
newMethodLocal:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
    "return a treeNode for a method local"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
    ^ VariableNode methodLocalNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   118
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   119
    "Created: / 06-08-2006 / 02:10:52 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   120
    "Modified: / 06-08-2006 / 13:29:46 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   121
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   122
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   123
newMethodSelector:sel
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
    ^ MethodNode new selector:sel
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   125
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   126
    "Created: / 06-08-2006 / 01:17:16 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   127
    "Modified: / 06-08-2006 / 13:29:56 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   128
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   130
newMethodSelector:sel arguments:argVars temporaries:localVars statements:statementNodes
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    ^ MethodNode new
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
        selector:sel 
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
        arguments:argVars
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   134
        locals:localVars 
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
        statements:statementNodes.
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
    "Modified: / 06-08-2006 / 13:30:01 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   138
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   139
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   140
newParameterVariable:aNode
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   141
    ^ Variable name:(aNode name)
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   142
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   143
    "Created: / 06-08-2006 / 14:23:25 / cg"
98
claus
parents:
diff changeset
   144
!
claus
parents:
diff changeset
   145
claus
parents:
diff changeset
   146
newReturnValue:anExpressionNode
claus
parents:
diff changeset
   147
    "return a treeNode for a method-return"
claus
parents:
diff changeset
   148
claus
parents:
diff changeset
   149
    ^ ReturnNode expression:anExpressionNode
claus
parents:
diff changeset
   150
!
claus
parents:
diff changeset
   151
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   152
newSelf
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
    ^ SelfNode new
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
    "Created: / 06-08-2006 / 13:51:17 / cg"
98
claus
parents:
diff changeset
   156
! !
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
!ProgramNodeBuilder class methodsFor:'documentation'!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   159
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
version
2900
a1349983b2e7 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 2117
diff changeset
   161
    ^ '$Header: /cvs/stx/stx/libcomp/ProgramNodeBuilder.st,v 1.7 2012-08-03 20:25:04 stefan Exp $'
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   162
! !