ProgramNodeBuilder.st
changeset 1785 1994a5b86791
parent 135 aa4f7b8f121e
child 2117 eb138ea841a8
equal deleted inserted replaced
1784:4380f89e1a91 1785:1994a5b86791
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Object subclass:#ProgramNodeBuilder 
    13 "{ Package: 'stx:libcomp' }"
    14        instanceVariableNames:''
    14 
    15        classVariableNames:''
    15 Object subclass:#ProgramNodeBuilder
    16        poolDictionaries:''
    16 	instanceVariableNames:''
    17        category:'System-Compiler ST-80-compatibility'
    17 	classVariableNames:''
       
    18 	poolDictionaries:''
       
    19 	category:'System-Compiler ST-80-compatibility'
    18 !
    20 !
    19 
    21 
    20 !ProgramNodeBuilder class methodsFor:'documentation'!
    22 !ProgramNodeBuilder class methodsFor:'documentation'!
    21 
    23 
    22 copyright
    24 copyright
    31  other person.  No title to or ownership of the software is
    33  other person.  No title to or ownership of the software is
    32  hereby transferred.
    34  hereby transferred.
    33 "
    35 "
    34 !
    36 !
    35 
    37 
    36 version
       
    37     ^ '$Header: /cvs/stx/stx/libcomp/ProgramNodeBuilder.st,v 1.4 1995-11-11 15:31:29 cg Exp $'
       
    38 !
       
    39 
       
    40 documentation
    38 documentation
    41 "
    39 "
    42     This is a pure mimicri class.
    40     This is a pure mimicri class.
    43     It is not used by ST/X, but provided to support limited
    41     It is not used by ST/X, but provided to support limited
    44     compatibility for applications which build up codetrees,
    42     compatibility for applications which build up codetrees,
    51 "
    49 "
    52 ! !
    50 ! !
    53 
    51 
    54 !ProgramNodeBuilder methodsFor:'tree building'!
    52 !ProgramNodeBuilder methodsFor:'tree building'!
    55 
    53 
       
    54 newBlockBody:statements
       
    55     ^ (BlockNode arguments:#() home:nil variables:#()) statements:statements
       
    56 
       
    57     "Created: / 06-08-2006 / 23:25:36 / cg"
       
    58 !
       
    59 
       
    60 newGlobal:name
       
    61     "return a treeNode for a global variable"
       
    62 
       
    63     ^ VariableNode globalNamed:name
       
    64 
       
    65     "Created: / 06-08-2006 / 01:37:56 / cg"
       
    66 !
       
    67 
    56 newLiteralValue:aConstantValue
    68 newLiteralValue:aConstantValue
    57     "return a treeNode for a literal constant"
    69     "return a treeNode for a literal constant"
    58 
    70 
       
    71 (aConstantValue isKindOf:Association) ifTrue:[self halt].
       
    72 
    59     ^ ConstantNode value:aConstantValue
    73     ^ ConstantNode value:aConstantValue
       
    74 
       
    75     "Modified: / 06-08-2006 / 15:16:04 / cg"
       
    76 !
       
    77 
       
    78 newMessageReceiver: receiverNode selector: selector
       
    79     ^ self newMessageReceiver: receiverNode selector: selector arguments: #()
       
    80 
       
    81     "Created: / 06-08-2006 / 02:59:55 / cg"
       
    82     "Modified: / 06-08-2006 / 13:29:33 / cg"
       
    83 !
       
    84 
       
    85 newMessageReceiver: receiverNode selector: selector arguments: arguments
       
    86     selector isUnarySelector ifTrue:[
       
    87         self assert:(arguments isEmptyOrNil).
       
    88         ^ UnaryNode receiver:receiverNode selector: selector args: arguments
       
    89     ].
       
    90     selector isBinarySelector ifTrue:[
       
    91         self assert:(arguments size == 1).
       
    92         ^ BinaryNode receiver:receiverNode selector: selector args: arguments
       
    93     ].
       
    94     self assert:(arguments notEmptyOrNil).
       
    95     ^ MessageNode receiver:receiverNode selector: selector args: arguments
       
    96 
       
    97     "Created: / 06-08-2006 / 03:02:33 / cg"
       
    98     "Modified: / 06-08-2006 / 14:00:47 / cg"
       
    99 !
       
   100 
       
   101 newMethodArgument:name
       
   102     "return a treeNode for a method arg"
       
   103 
       
   104     ^ VariableNode methodArgumentNamed:name
       
   105 
       
   106     "Created: / 06-08-2006 / 01:15:33 / cg"
       
   107     "Modified: / 06-08-2006 / 13:29:42 / cg"
       
   108 !
       
   109 
       
   110 newMethodLocal:name
       
   111     "return a treeNode for a method local"
       
   112 
       
   113     ^ VariableNode methodLocalNamed:name
       
   114 
       
   115     "Created: / 06-08-2006 / 02:10:52 / cg"
       
   116     "Modified: / 06-08-2006 / 13:29:46 / cg"
       
   117 !
       
   118 
       
   119 newMethodSelector:sel
       
   120     ^ MethodNode new selector:sel
       
   121 
       
   122     "Created: / 06-08-2006 / 01:17:16 / cg"
       
   123     "Modified: / 06-08-2006 / 13:29:56 / cg"
       
   124 !
       
   125 
       
   126 newMethodSelector:sel arguments:argVars temporaries:localVars statements:statementNodes
       
   127     ^ MethodNode new
       
   128         selector:sel 
       
   129         arguments:argVars
       
   130         locals:localVars 
       
   131         statements:statementNodes.
       
   132 
       
   133     "Modified: / 06-08-2006 / 13:30:01 / cg"
       
   134 !
       
   135 
       
   136 newParameterVariable:aNode
       
   137     ^ Variable name:(aNode name)
       
   138 
       
   139     "Created: / 06-08-2006 / 14:23:25 / cg"
    60 !
   140 !
    61 
   141 
    62 newReturnValue:anExpressionNode
   142 newReturnValue:anExpressionNode
    63     "return a treeNode for a method-return"
   143     "return a treeNode for a method-return"
    64 
   144 
    65     ^ ReturnNode expression:anExpressionNode
   145     ^ ReturnNode expression:anExpressionNode
    66 !
   146 !
    67 
   147 
    68 newMethodSelector:sel arguments:argVars temporaries:localVars statements:statementNodes
   148 newSelf
    69     "mhmh - in ST/X we have no methodNodes ...."
   149     ^ SelfNode new
    70     ^ MethodNode new
   150 
    71 	selector:sel 
   151     "Created: / 06-08-2006 / 13:51:17 / cg"
    72 	arguments:argVars
       
    73 	locals:localVars 
       
    74 	statements:statementNodes.
       
    75 ! !
   152 ! !
       
   153 
       
   154 !ProgramNodeBuilder class methodsFor:'documentation'!
       
   155 
       
   156 version
       
   157     ^ '$Header: /cvs/stx/stx/libcomp/ProgramNodeBuilder.st,v 1.5 2006-08-07 10:19:16 cg Exp $'
       
   158 ! !