summaryrefslogtreecommitdiff
path: root/sources/scalac/atree/APrimitive.java
blob: 034a9f4d19c51e73630ce44a783695b9283984bc (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
/*     ____ ____  ____ ____  ______                                     *\
**    / __// __ \/ __// __ \/ ____/    SOcos COmpiles Scala             **
**  __\_ \/ /_/ / /__/ /_/ /\_ \       (c) 2002, LAMP/EPFL              **
** /_____/\____/\___/\____/____/                                        **
\*                                                                      */

// $Id$

package scalac.atree;

/** This class represents a primitive operation. */
public class APrimitive {

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

    // type : (type) => type
    // range: type <- { BOOL, Ix, Ux, Rx }
    // jvm  : {i, l, f, d}neg
    public case Negation(ATypeKind kind);

    // type : zero ? (type) => BOOL : (type,type) => BOOL
    // range: type <- { BOOL, Ix, Ux, Rx, REF }
    // jvm  : if{eq, ne, lt, ge, le, gt}, if{null, nonnull}
    //        if_icmp{eq, ne, lt, ge, le, gt}, if_acmp{eq,ne}
    public case Test(ATestOp op, ATypeKind kind, boolean zero);

    // type : (type,type) => I4
    // range: type <- { Ix, Ux, Rx }
    // jvm  : lcmp, {f, d}cmp{l, g}
    public case Comparison(AComparisonOp op, ATypeKind kind);

    // type : (type,type) => type
    // range: type <- { Ix, Ux, Rx }
    // jvm  : {i, l, f, d}{add, sub, mul, div, rem}
    public case Arithmetic(AArithmeticOp op, ATypeKind kind);

    // type : (type,type) => type
    // range: type <- { BOOL, Ix, Ux }
    // jvm  : {i, l}{and, or, xor}
    public case Logical(ALogicalOp op, ATypeKind kind);

    // type : (type,I4) => type
    // range: type <- { Ix, Ux }
    // jvm  : {i, l}{shl, ushl, shr}
    public case Shift(AShiftOp op, ATypeKind kind);

    // type : (src) => dst
    // range: src,dst <- { Ix, Ux, Rx }
    // jvm  : i2{l, f, d}, l2{i, f, d}, f2{i, l, d}, d2{i, l, f}, i2{b, c, s}
    public case Conversion(ATypeKind src, ATypeKind dst);

    // type : (Array[REF]) => I4
    // range: type <- { BOOL, Ix, Ux, Rx, REF }
    // jvm  : arraylength
    public case ArrayLength(ATypeKind kind);

    // type : (lf,rg) => STR
    // range: lf,rg <- { BOOL, Ix, Ux, Rx, REF, STR }
    // jvm  : -
    public case StringConcat(ATypeKind lf, ATypeKind rg);

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

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

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