KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > CodeGen > Expressions


1 /* $Id: Expressions.java,v 1.2 2004/05/20 14:23:51 bures Exp $ */
2 package SOFA.SOFAnode.Made.CodeGen;
3
4 import java.rmi.RemoteException;
5
6 import SOFA.SOFAnode.Made.TIR.ExprBinOperationDef;
7 import SOFA.SOFAnode.Made.TIR.ExprConstant;
8 import SOFA.SOFAnode.Made.TIR.ExprEnum;
9 import SOFA.SOFAnode.Made.TIR.ExprOperDef;
10 import SOFA.SOFAnode.Made.TIR.ExprOperKind;
11 import SOFA.SOFAnode.Made.TIR.ExprUnOperationDef;
12  
13 /** Some functions for handling expressions.
14   *
15   * @author Petr Hnetynka
16   */

17 class Expressions {
18   /** Add all referenced objects (constants, enums) that are in <tt>expr</tt> to the <tt>list</tt>.
19     *
20     * @param expr scanned expression
21     * @param list add all objects to this list
22     * @exception RemoteException remote exception
23     * @exception TIRAccessException error in access to the TIR
24     */

25   static void scanExpr(ExprOperDef expr, ObjectList list) throws RemoteException, TIRAccessException {
26     switch (expr.get_eok_kind().value()) {
27     case ExprOperKind.eok_or:
28     case ExprOperKind.eok_xor:
29     case ExprOperKind.eok_and:
30     case ExprOperKind.eok_shr:
31     case ExprOperKind.eok_shl:
32     case ExprOperKind.eok_plus:
33     case ExprOperKind.eok_minus:
34     case ExprOperKind.eok_mul:
35     case ExprOperKind.eok_div:
36     case ExprOperKind.eok_mod:
37       ExprBinOperationDef bop = (ExprBinOperationDef) expr;
38       scanExpr(bop.operand1(), list);
39       scanExpr(bop.operand2(), list);
40       break;
41     case ExprOperKind.eok_unminus:
42     case ExprOperKind.eok_unplus:
43     case ExprOperKind.eok_untilde:
44       scanExpr(((ExprUnOperationDef) expr).operand(), list);
45       break;
46     case ExprOperKind.eok_short:
47     case ExprOperKind.eok_long:
48     case ExprOperKind.eok_longlong:
49     case ExprOperKind.eok_unsigshort:
50     case ExprOperKind.eok_unsiglong:
51     case ExprOperKind.eok_unsiglonglong:
52     case ExprOperKind.eok_float:
53     case ExprOperKind.eok_double:
54     case ExprOperKind.eok_octet:
55     case ExprOperKind.eok_char:
56     case ExprOperKind.eok_wchar:
57     case ExprOperKind.eok_string:
58     case ExprOperKind.eok_wstring:
59     case ExprOperKind.eok_default:
60     case ExprOperKind.eok_boolean:
61     case ExprOperKind.eok_longdouble:
62     case ExprOperKind.eok_fixed:
63       break;
64     
65     case ExprOperKind.eok_property:
66       break;
67     case ExprOperKind.eok_constant:
68       list.addObject(((ExprConstant) expr).ref_const());
69       break;
70     case ExprOperKind.eok_enum:
71       list.addObject(((ExprEnum) expr).enum());
72       break;
73
74     }
75   }
76 }
77
Popular Tags