1 cananian 1.1.2.4 // InterpreterAllocationStrategy.java, created Sat Mar 27 17:05:08 1999 by duncan
 2 cananian 1.1.2.3 // Copyright (C) 1998 Duncan Bryce <duncan@lcs.mit.edu>
 3 cananian 1.1.2.3 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 duncan   1.1.2.1 package harpoon.Interpret.Tree;
 5 duncan   1.1.2.1 
 6 duncan   1.1.2.1 import harpoon.IR.Tree.ESEQ;
 7 duncan   1.1.2.1 import harpoon.IR.Tree.Exp;
 8 duncan   1.1.2.1 import harpoon.IR.Tree.ExpList;
 9 duncan   1.1.2.1 import harpoon.IR.Tree.NAME;
10 duncan   1.1.2.6 import harpoon.IR.Tree.NATIVECALL;
11 duncan   1.1.2.1 import harpoon.IR.Tree.TEMP;
12 duncan   1.1.2.1 import harpoon.IR.Tree.Type;
13 duncan   1.1.2.1 import harpoon.IR.Tree.TreeFactory;
14 duncan   1.1.2.1 import harpoon.Temp.Label;
15 duncan   1.1.2.1 import harpoon.Temp.Temp;
16 duncan   1.1.2.1 
17 duncan   1.1.2.5 /**
18 duncan   1.1.2.5  * An allocation strategy designed specifically for use by the Tree 
19 duncan   1.1.2.5  * interpreter.  Probably shouldn't be used for anything else.  
20 duncan   1.1.2.5  *
21 cananian 1.1.2.3  * @author Duncan Bryce <duncan@lcs.mit.edu>
22 cananian 1.2      * @version $Id: InterpreterAllocationStrategy.java,v 1.2 2002/02/25 21:05:57 cananian Exp $
23 cananian 1.1.2.2  */
24 duncan   1.1.2.5 class InterpreterAllocationStrategy implements AllocationStrategy {
25 duncan   1.1.2.1 
26 duncan   1.1.2.1     public InterpreterAllocationStrategy() { }
27 duncan   1.1.2.1 
28 duncan   1.1.2.1     public Exp memAlloc(Exp size) { 
29 duncan   1.1.2.1         TreeFactory tf = size.getFactory();
30 duncan   1.1.2.1 
31 duncan   1.1.2.1         TEMP rv = new TEMP(tf, size, Type.POINTER, new Temp(tf.tempFactory()));
32 duncan   1.1.2.1 
33 duncan   1.1.2.1         return 
34 duncan   1.1.2.1             new ESEQ
35 duncan   1.1.2.1             (tf, size, 
36 duncan   1.1.2.6              new NATIVECALL
37 duncan   1.1.2.6              (tf, size, rv,  
38 duncan   1.1.2.1               new NAME(tf, size, new Label("RUNTIME_MALLOC")),
39 duncan   1.1.2.1               new ExpList(size, null)),
40 duncan   1.1.2.1              rv);
41 duncan   1.1.2.1     }
42 cananian 1.2     }