ProgramNodeBuilder.st
author Claus Gittinger <cg@exept.de>
Mon, 07 Aug 2006 12:19:16 +0200
changeset 1785 1994a5b86791
parent 135 aa4f7b8f121e
child 2117 eb138ea841a8
permissions -rw-r--r--
more compatibility
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
"
claus
parents:
diff changeset
    12
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    13
"{ Package: 'stx:libcomp' }"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    14
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    15
Object subclass:#ProgramNodeBuilder
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    16
	instanceVariableNames:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    17
	classVariableNames:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    18
	poolDictionaries:''
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    19
	category:'System-Compiler ST-80-compatibility'
98
claus
parents:
diff changeset
    20
!
claus
parents:
diff changeset
    21
claus
parents:
diff changeset
    22
!ProgramNodeBuilder class methodsFor:'documentation'!
claus
parents:
diff changeset
    23
claus
parents:
diff changeset
    24
copyright
claus
parents:
diff changeset
    25
"
claus
parents:
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
    27
	      All Rights Reserved
claus
parents:
diff changeset
    28
claus
parents:
diff changeset
    29
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    34
 hereby transferred.
claus
parents:
diff changeset
    35
"
claus
parents:
diff changeset
    36
!
claus
parents:
diff changeset
    37
claus
parents:
diff changeset
    38
documentation
claus
parents:
diff changeset
    39
"
claus
parents:
diff changeset
    40
    This is a pure mimicri class.
claus
parents:
diff changeset
    41
    It is not used by ST/X, but provided to support limited
claus
parents:
diff changeset
    42
    compatibility for applications which build up codetrees,
claus
parents:
diff changeset
    43
    knowing internals of ST-80's compiler class hierarchy.
claus
parents:
diff changeset
    44
    This classes protocol is not (not meant to be) fully covering
claus
parents:
diff changeset
    45
    the corresponding ST-80's classes protocol. It maps ST-80 messages
claus
parents:
diff changeset
    46
    to corresponding ST/X messages (as far as possible).
claus
parents:
diff changeset
    47
claus
parents:
diff changeset
    48
    NO WARRANTY and GUARANTEE; this class may be removed without notice.
claus
parents:
diff changeset
    49
"
claus
parents:
diff changeset
    50
! !
claus
parents:
diff changeset
    51
claus
parents:
diff changeset
    52
!ProgramNodeBuilder methodsFor:'tree building'!
claus
parents:
diff changeset
    53
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
newBlockBody:statements
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
    ^ (BlockNode arguments:#() home:nil variables:#()) statements:statements
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
    "Created: / 06-08-2006 / 23:25:36 / cg"
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
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    60
newGlobal:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
    "return a treeNode for a global variable"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    62
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    63
    ^ VariableNode globalNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    64
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    65
    "Created: / 06-08-2006 / 01:37:56 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    66
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    67
98
claus
parents:
diff changeset
    68
newLiteralValue:aConstantValue
claus
parents:
diff changeset
    69
    "return a treeNode for a literal constant"
claus
parents:
diff changeset
    70
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    71
(aConstantValue isKindOf:Association) ifTrue:[self halt].
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    72
98
claus
parents:
diff changeset
    73
    ^ ConstantNode value:aConstantValue
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    74
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    75
    "Modified: / 06-08-2006 / 15:16:04 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    76
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    77
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    78
newMessageReceiver: receiverNode selector: selector
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    79
    ^ self newMessageReceiver: receiverNode selector: selector arguments: #()
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
    "Created: / 06-08-2006 / 02:59:55 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    82
    "Modified: / 06-08-2006 / 13:29:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    83
!
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
newMessageReceiver: receiverNode selector: selector arguments: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    86
    selector isUnarySelector ifTrue:[
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    87
        self assert:(arguments isEmptyOrNil).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    88
        ^ UnaryNode receiver:receiverNode selector: selector args: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    89
    ].
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    90
    selector isBinarySelector ifTrue:[
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    91
        self assert:(arguments size == 1).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    92
        ^ BinaryNode 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
    self assert:(arguments notEmptyOrNil).
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
    ^ MessageNode receiver:receiverNode selector: selector args: arguments
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    96
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    97
    "Created: / 06-08-2006 / 03:02:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
    "Modified: / 06-08-2006 / 14:00:47 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
!
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
newMethodArgument:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
    "return a treeNode for a method arg"
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
    ^ VariableNode methodArgumentNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   106
    "Created: / 06-08-2006 / 01:15:33 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   107
    "Modified: / 06-08-2006 / 13:29:42 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
!
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
newMethodLocal:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   111
    "return a treeNode for a method local"
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
    ^ VariableNode methodLocalNamed:name
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   114
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
    "Created: / 06-08-2006 / 02:10:52 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
    "Modified: / 06-08-2006 / 13:29:46 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
!
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
newMethodSelector:sel
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   120
    ^ MethodNode new selector:sel
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
    "Created: / 06-08-2006 / 01:17:16 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   123
    "Modified: / 06-08-2006 / 13:29:56 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
!
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
newMethodSelector:sel arguments:argVars temporaries:localVars statements:statementNodes
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   127
    ^ MethodNode new
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   128
        selector:sel 
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
        arguments:argVars
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   130
        locals:localVars 
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
        statements:statementNodes.
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
    "Modified: / 06-08-2006 / 13:30:01 / cg"
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   134
!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
newParameterVariable:aNode
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
    ^ Variable name:(aNode name)
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
    "Created: / 06-08-2006 / 14:23:25 / cg"
98
claus
parents:
diff changeset
   140
!
claus
parents:
diff changeset
   141
claus
parents:
diff changeset
   142
newReturnValue:anExpressionNode
claus
parents:
diff changeset
   143
    "return a treeNode for a method-return"
claus
parents:
diff changeset
   144
claus
parents:
diff changeset
   145
    ^ ReturnNode expression:anExpressionNode
claus
parents:
diff changeset
   146
!
claus
parents:
diff changeset
   147
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   148
newSelf
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   149
    ^ SelfNode new
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   150
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   151
    "Created: / 06-08-2006 / 13:51:17 / cg"
98
claus
parents:
diff changeset
   152
! !
1785
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
!ProgramNodeBuilder class methodsFor:'documentation'!
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   156
version
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
    ^ '$Header: /cvs/stx/stx/libcomp/ProgramNodeBuilder.st,v 1.5 2006-08-07 10:19:16 cg Exp $'
1994a5b86791 more compatibility
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
! !