KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > javaToJimple > jj > ast > JjNodeFactory_c


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.javaToJimple.jj.ast;
21
22 import polyglot.ast.*;
23 import polyglot.ext.jl.ast.*;
24 import polyglot.types.Flags;
25 import polyglot.types.Package;
26 import polyglot.types.Type;
27 import polyglot.types.Qualifier;
28 import polyglot.util.*;
29 import java.util.*;
30
31 /**
32  * NodeFactory for jj extension.
33  */

34 public class JjNodeFactory_c extends NodeFactory_c implements JjNodeFactory {
35     // TODO: Implement factory methods for new AST nodes.
36
// TODO: Override factory methods for overriden AST nodes.
37
// TODO: Override factory methods for AST nodes with new extension nodes.
38

39     public JjComma_c JjComma(Position pos, Expr first, Expr second){
40         JjComma_c n = new JjComma_c(pos, first, second);
41         return n;
42     }
43    
44     public JjAccessField_c JjAccessField(Position pos, Call getMeth, Call setMeth, Field field){
45         JjAccessField_c n = new JjAccessField_c(pos, getMeth, setMeth, field);
46         return n;
47     }
48     
49     public Unary Unary(Position pos, Unary.Operator op, Expr expr) {
50         Unary n = new JjUnary_c(pos, op, expr);
51         n = (Unary)n.ext(extFactory().extUnary());
52         n = (Unary)n.del(delFactory().delUnary());
53         return n;
54     }
55     
56     public Binary Binary(Position pos, Expr left, Binary.Operator op, Expr right) {
57         Binary n = new JjBinary_c(pos, left, op, right);
58         n = (Binary)n.ext(extFactory().extBinary());
59         n = (Binary)n.del(delFactory().delBinary());
60         return n;
61     }
62
63     public Assign Assign(Position pos, Expr left, Assign.Operator op, Expr right) {
64         Assign n;
65         if (left instanceof Local) {
66             return LocalAssign(pos, (Local)left, op, right);
67         }
68         else if (left instanceof Field) {
69             return FieldAssign(pos, (Field)left, op, right);
70         }
71         else if (left instanceof ArrayAccess) {
72             return ArrayAccessAssign(pos, (ArrayAccess)left, op, right);
73         }
74         return AmbAssign(pos, left, op, right);
75     }
76
77     
78     public LocalAssign LocalAssign(Position pos, Local left, Assign.Operator op, Expr right) {
79         LocalAssign n = new JjLocalAssign_c(pos, left, op, right);
80         n = (LocalAssign)n.ext(extFactory().extLocalAssign());
81         n = (LocalAssign)n.del(delFactory().delLocalAssign());
82         return n;
83     }
84     
85     public LocalDecl LocalDecl(Position pos, Flags flags, TypeNode type, String JavaDoc name, Expr init) {
86         LocalDecl n = new JjLocalDecl_c(pos, flags, type, name, init);
87         n = (LocalDecl)n.ext(extFactory().extLocalAssign());
88         n = (LocalDecl)n.del(delFactory().delLocalAssign());
89         return n;
90     }
91     
92     public FieldAssign FieldAssign(Position pos, Field left, Assign.Operator op, Expr right) {
93         FieldAssign n = new JjFieldAssign_c(pos, left, op, right);
94         n = (FieldAssign)n.ext(extFactory().extFieldAssign());
95         n = (FieldAssign)n.del(delFactory().delFieldAssign());
96         return n;
97     }
98     
99     public FieldDecl FieldDecl(Position pos, Flags flags, TypeNode type, String JavaDoc name, Expr init) {
100         FieldDecl n = new JjFieldDecl_c(pos, flags, type, name, init);
101         n = (FieldDecl)n.ext(extFactory().extFieldAssign());
102         n = (FieldDecl)n.del(delFactory().delFieldAssign());
103         return n;
104     }
105     
106     public ArrayAccessAssign ArrayAccessAssign(Position pos, ArrayAccess left, Assign.Operator op, Expr right) {
107         ArrayAccessAssign n = new JjArrayAccessAssign_c(pos, left, op, right);
108         n = (ArrayAccessAssign)n.ext(extFactory().extArrayAccessAssign());
109         n = (ArrayAccessAssign)n.del(delFactory().delArrayAccessAssign());
110         return n;
111     }
112     
113     public Cast Cast(Position pos, TypeNode type, Expr expr) {
114         Cast n = new JjCast_c(pos, type, expr);
115         n = (Cast)n.ext(extFactory().extCast());
116         n = (Cast)n.del(delFactory().delCast());
117         return n;
118     }
119     
120     public NewArray NewArray(Position pos, TypeNode base, List dims, int addDims, ArrayInit init) {
121         //System.out.println("new array pos: "+pos);
122
return super.NewArray(pos, base, dims, addDims, init);
123     }
124     
125     public ArrayInit ArrayInit(Position pos, List elements) {
126         ArrayInit n = new JjArrayInit_c(pos, elements);
127         n = (ArrayInit)n.ext(extFactory().extArrayInit());
128         n = (ArrayInit)n.del(delFactory().delArrayInit());
129         return n;
130     }
131
132     public Return Return(Position pos, Expr expr) {
133         Return n = new JjReturn_c(pos, expr);
134         n = (Return)n.ext(extFactory().extReturn());
135         n = (Return)n.del(delFactory().delReturn());
136         return n;
137     }
138         
139 }
140
Popular Tags