summaryrefslogtreecommitdiff
path: root/sources/scalac/atree
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-02-09 16:31:26 +0000
committerpaltherr <paltherr@epfl.ch>2004-02-09 16:31:26 +0000
commit0fe104ec4317992b1b0154a876c81bc0be1f5a02 (patch)
tree514b6bcc2cff79061c5d41a120ee2820ade696e9 /sources/scalac/atree
parent8d6a1e3cfe585fc1432d295cb3b884baad9fbc38 (diff)
downloadscala-0fe104ec4317992b1b0154a876c81bc0be1f5a02.tar.gz
scala-0fe104ec4317992b1b0154a876c81bc0be1f5a02.tar.bz2
scala-0fe104ec4317992b1b0154a876c81bc0be1f5a02.zip
- Added primitive creation methods
Diffstat (limited to 'sources/scalac/atree')
-rw-r--r--sources/scalac/atree/ATreeFactory.java305
1 files changed, 303 insertions, 2 deletions
diff --git a/sources/scalac/atree/ATreeFactory.java b/sources/scalac/atree/ATreeFactory.java
index 422c3376c6..e28b220340 100644
--- a/sources/scalac/atree/ATreeFactory.java
+++ b/sources/scalac/atree/ATreeFactory.java
@@ -62,12 +62,37 @@ public class ATreeFactory {
}
/** Builds an Apply node. */
- public ACode Apply(Tree t, AFunction function, Type[] targs,ACode[] vargs){
- ACode.Apply code = ACode.Apply(function, targs, vargs);
+ public ACode Apply(Tree t, AFunction function, Type[] ts, ACode[] vs) {
+ ACode.Apply code = ACode.Apply(function, ts, vs);
code.pos = t.pos;
return code;
}
+ /** Builds an Apply node. */
+ public ACode Apply(Tree t, AFunction function, Type[] ts) {
+ return Apply(t, function, ts, ACode.EMPTY_ARRAY);
+ }
+
+ /** Builds an Apply node. */
+ public ACode Apply(Tree t, AFunction function, ACode[] vs) {
+ return Apply(t, function, Type.EMPTY_ARRAY, vs);
+ }
+
+ /** Builds an Apply node. */
+ public ACode Apply(Tree t, AFunction function) {
+ return Apply(t, function, Type.EMPTY_ARRAY, ACode.EMPTY_ARRAY);
+ }
+
+ /** Builds an Apply node. */
+ public ACode Apply(Tree t, APrimitive primitive, ACode v0) {
+ return Apply(t, AFunction.Primitive(primitive), new ACode[] {v0});
+ }
+
+ /** Builds an Apply node. */
+ public ACode Apply(Tree t, APrimitive primitive, ACode v0, ACode v1) {
+ return Apply(t, AFunction.Primitive(primitive), new ACode[] {v0,v1});
+ }
+
/** Builds an IsAs node. */
public ACode IsAs(Tree t, ACode value, Type type, boolean cast) {
ACode.IsAs code = ACode.IsAs(value, type, cast);
@@ -139,6 +164,282 @@ public class ATreeFactory {
}
//########################################################################
+ // Public Methods - Building primitive operations
+
+ /** Builds a negation operation */
+ public ACode NOT(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, NOT(kind), v0);
+ }
+
+ /** Builds an EQ operation */
+ public ACode EQ(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, EQ(kind, true), v0);
+ }
+
+ /** Builds a NE operation */
+ public ACode NE(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, NE(kind, true), v0);
+ }
+
+ /** Builds a LT operation */
+ public ACode LT(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, LT(kind, true), v0);
+ }
+
+ /** Builds a GE operation */
+ public ACode GE(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, GE(kind, true), v0);
+ }
+
+ /** Builds a LE operation */
+ public ACode LE(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, LE(kind, true), v0);
+ }
+
+ /** Builds a GT operation */
+ public ACode GT(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, GT(kind, true), v0);
+ }
+
+ /** Builds an EQ operation */
+ public ACode EQ(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, EQ(kind, false), v0, v1);
+ }
+
+ /** Builds a NE operation */
+ public ACode NE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, NE(kind, false), v0, v1);
+ }
+
+ /** Builds a LT operation */
+ public ACode LT(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, LT(kind, false), v0, v1);
+ }
+
+ /** Builds a GE operation */
+ public ACode GE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, GE(kind, false), v0, v1);
+ }
+
+ /** Builds a LE operation */
+ public ACode LE(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, LE(kind, false), v0, v1);
+ }
+
+ /** Builds a GT operation */
+ public ACode GT(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, GT(kind, false), v0, v1);
+ }
+
+ /** Builds a CMPL operation */
+ public ACode CMPL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, CMPL(kind), v0, v1);
+ }
+
+ /** Builds a CMP operation */
+ public ACode CMP(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, CMP(kind), v0, v1);
+ }
+
+ /** Builds a CMPG operation */
+ public ACode CMPG(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, CMPG(kind), v0, v1);
+ }
+
+ /** Builds an ADD operation */
+ public ACode ADD(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, ADD(kind), v0, v1);
+ }
+
+ /** Builds a SUB operation */
+ public ACode SUB(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, SUB(kind), v0, v1);
+ }
+
+ /** Builds a MUL operation */
+ public ACode MUL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, MUL(kind), v0, v1);
+ }
+
+ /** Builds a DIV operation */
+ public ACode DIV(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, DIV(kind), v0, v1);
+ }
+
+ /** Builds a REM operation */
+ public ACode REM(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, REM(kind), v0, v1);
+ }
+
+ /** Builds an AND operation. */
+ public ACode AND(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, AND(kind), v0, v1);
+ }
+
+ /** Builds an OR operation. */
+ public ACode OR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, OR(kind), v0, v1);
+ }
+
+ /** Builds an XOR operation. */
+ public ACode XOR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, XOR(kind), v0, v1);
+ }
+
+ /** Builds a LSL operation. */
+ public ACode LSL(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, LSL(kind), v0, v1);
+ }
+
+ /** Builds a LSR operation. */
+ public ACode LSR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, LSR(kind), v0, v1);
+ }
+
+ /** Builds an ASR operation. */
+ public ACode ASR(Tree t, ATypeKind kind, ACode v0, ACode v1) {
+ return Apply(t, ASR(kind), v0, v1);
+ }
+
+ /** Builds a value conversion operation. */
+ public ACode CONVERT(Tree t, ATypeKind src, ATypeKind dst, ACode v0) {
+ return Apply(t, CONVERT(src, dst), v0);
+ }
+
+ /** Builds an array length operation. */
+ public ACode LENGTH(Tree t, ATypeKind kind, ACode v0) {
+ return Apply(t, LENGTH(kind), v0);
+ }
+
+ /** Builds a string concatenation operation. */
+ public ACode CONCAT(Tree t, ATypeKind lf, ATypeKind rg, ACode v0,ACode v1){
+ return Apply(t, CONCAT(lf, rg), v0, v1);
+ }
+
+ //########################################################################
+ // Public Methods - Building primitives
+
+ /** Builds a negation primitive */
+ public APrimitive NOT(ATypeKind kind) {
+ return APrimitive.Negation(kind);
+ }
+
+ /** Builds an EQ primitive */
+ public APrimitive EQ(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.EQ, kind, zero);
+ }
+
+ /** Builds a NE primitive */
+ public APrimitive NE(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.NE, kind, zero);
+ }
+
+ /** Builds a LT primitive */
+ public APrimitive LT(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.LT, kind, zero);
+ }
+
+ /** Builds a GE primitive */
+ public APrimitive GE(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.GE, kind, zero);
+ }
+
+ /** Builds a LE primitive */
+ public APrimitive LE(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.LE, kind, zero);
+ }
+
+ /** Builds a GT primitive */
+ public APrimitive GT(ATypeKind kind, boolean zero) {
+ return APrimitive.Test(ATestOp.GT, kind, zero);
+ }
+
+ /** Builds a CMPL primitive */
+ public APrimitive CMPL(ATypeKind kind) {
+ return APrimitive.Comparison(AComparisonOp.CMPL, kind);
+ }
+
+ /** Builds a CMP primitive */
+ public APrimitive CMP(ATypeKind kind) {
+ return APrimitive.Comparison(AComparisonOp.CMP, kind);
+ }
+
+ /** Builds a CMPG primitive */
+ public APrimitive CMPG(ATypeKind kind) {
+ return APrimitive.Comparison(AComparisonOp.CMPG, kind);
+ }
+
+ /** Builds an ADD primitive */
+ public APrimitive ADD(ATypeKind kind) {
+ return APrimitive.Arithmetic(AArithmeticOp.ADD, kind);
+ }
+
+ /** Builds a SUB primitive */
+ public APrimitive SUB(ATypeKind kind) {
+ return APrimitive.Arithmetic(AArithmeticOp.SUB, kind);
+ }
+
+ /** Builds a MUL primitive */
+ public APrimitive MUL(ATypeKind kind) {
+ return APrimitive.Arithmetic(AArithmeticOp.MUL, kind);
+ }
+
+ /** Builds a DIV primitive */
+ public APrimitive DIV(ATypeKind kind) {
+ return APrimitive.Arithmetic(AArithmeticOp.DIV, kind);
+ }
+
+ /** Builds a REM primitive */
+ public APrimitive REM(ATypeKind kind) {
+ return APrimitive.Arithmetic(AArithmeticOp.REM, kind);
+ }
+
+ /** Builds an AND primitive. */
+ public APrimitive AND(ATypeKind kind) {
+ return APrimitive.Logical(ALogicalOp.AND, kind);
+ }
+
+ /** Builds an OR primitive. */
+ public APrimitive OR(ATypeKind kind) {
+ return APrimitive.Logical(ALogicalOp.OR, kind);
+ }
+
+ /** Builds an XOR primitive. */
+ public APrimitive XOR(ATypeKind kind) {
+ return APrimitive.Logical(ALogicalOp.XOR, kind);
+ }
+
+ /** Builds a LSL primitive. */
+ public APrimitive LSL(ATypeKind kind) {
+ return APrimitive.Shift(AShiftOp.ASL, kind);
+ }
+
+ /** Builds a LSR primitive. */
+ public APrimitive LSR(ATypeKind kind) {
+ return APrimitive.Shift(AShiftOp.LSR, kind);
+ }
+
+ /** Builds an ASR primitive. */
+ public APrimitive ASR(ATypeKind kind) {
+ return APrimitive.Shift(AShiftOp.ASR, kind);
+ }
+
+ /** Builds a value conversion primitive. */
+ public APrimitive CONVERT(ATypeKind src, ATypeKind dst) {
+ return APrimitive.Conversion(src, dst);
+ }
+
+ /** Builds an array length primitive. */
+ public APrimitive LENGTH(ATypeKind kind) {
+ return APrimitive.ArrayLength(kind);
+ }
+
+ /** Builds a string concatenation primitive. */
+ public APrimitive CONCAT(ATypeKind lf, ATypeKind rg) {
+ return APrimitive.StringConcat(lf, rg);
+ }
+
+ //########################################################################
// Public Methods - Building constants
/** Builds a BOOLEAN constant of given value. */