summaryrefslogtreecommitdiff
path: root/sources/scalac/atree/ACode.java
blob: 3e65d41829796c4723a1a1289caf2ebf8c61b0e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package scalac.atree;

import scalac.symtab.Symbol;
import scalac.symtab.Type;

/** This class represents attributed code. */
public class ACode {

    //########################################################################
    // Public Constants

    public static final ACode[] EMPTY_ARRAY = new ACode[0];

    //########################################################################
    // Public Cases

    // jvm  : -
    public case Void;

    // jvm  : aload_0
    public case This(Symbol clasz);

    // jvm  : {b, s}ipush, ldc{ ,_w, 2_w}, aconst_null
    // jvm  : iconst_{m1, 2, 3, 4, 5}, {i, l, f, d}const_{0, 1}, fconst_2
    public case Constant(AConstant constant);

    // jvm  : get{static, field}
    // jvm  : {i, l, f, d, a}load{, _0, _1, _2, _3}
    // jvm  : {i, l, f, d, a, b, c, s}aload
    public case Load(ALocation location);

    // jvm  : put{static, field}
    // jvm  : {i, l, f, d, a}store{, _0, _1, _2, _3}
    // jvm  : {i, l, f, d, a, b, c, s}store
    public case Store(ALocation location, ACode value);

    // jvm  : new, invoke{static, virtual, interface, special}, {, a}newarray
    // jvm  : <see also in APrimitive>
    public case Apply(AFunction function, Type[] targs, ACode[] vargs);

    // jvm  : instanceof, checkcast
    public case IsAs(ACode value, Type type, boolean cast);

    // jvm  : -
    public case If(ACode test, ACode success, ACode failure);

    // jvm  : {tables, lookup}switch
    public case Switch(ACode test, int[][] tags, ACode[] bodies);

    // jvm  : monitor{enter, exit}
    public case Synchronized(ACode lock, ACode value);

    // jvm  : -
    public case Block(Symbol[] locals, ACode[] statements, ACode value);

    // jvm  : -
    public case Label(Symbol label, Symbol[] locals, ACode value);

    // jvm  : goto, goto_w
    public case Goto(Symbol label, ACode[] vargs);

    // jvm  : {i, l, f, d, a, }return
    public case Return(Symbol function, ACode value);

    // jvm  : athrow
    public case Throw(ACode value);

    // jvm  : pop, pop2
    public case Drop(ACode value, Type type);

    // jvm  : nop, dup{, _x1, _x2, 2, 2_x1, 2_x2}, swap
    // jvm  : multianewarray, iinc, jsr{, _w}, ret, wide
    // NOT MAPPED

    //########################################################################
    // Public Fields

    /** The source file position */
    public int pos;

    //########################################################################
    // Public Methods

    /** Returns a string representation of this code. */
    public String toString() {
        return new ATreePrinter().printCode(this).toString();
    }

    //########################################################################
}