From e721ad85bbb88951a6a84e9427f576d492cfbae9 Mon Sep 17 00:00:00 2001 From: paltherr Date: Thu, 6 Nov 2003 14:03:54 +0000 Subject: - Removed atree/ACodeFactory.java - Added atree/ATreeFactory.java --- sources/scalac/atree/ACodeFactory.java | 135 ------------------- sources/scalac/atree/ATreeFactory.java | 232 +++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 135 deletions(-) delete mode 100644 sources/scalac/atree/ACodeFactory.java create mode 100644 sources/scalac/atree/ATreeFactory.java (limited to 'sources/scalac/atree') diff --git a/sources/scalac/atree/ACodeFactory.java b/sources/scalac/atree/ACodeFactory.java deleted file mode 100644 index 141814fd12..0000000000 --- a/sources/scalac/atree/ACodeFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scalac.atree; - -import scalac.ast.Tree; -import scalac.symtab.Symbol; -import scalac.symtab.Type; - -/** This class implements an attributed code factory. */ -public class ACodeFactory { - - //######################################################################## - // Public Fields - - /** The unique Void node */ - public final ACode Void = ACode.Void; - - //######################################################################## - // Public Methods - - /** Creates a This node. */ - public ACode This(Tree t, Symbol clasz) { - ACode.This code = ACode.This(clasz); - code.pos = t.pos; - return code; - } - - /** Creates a Constant node. */ - public ACode Constant(Tree t, AConstant constant) { - ACode.Constant code = ACode.Constant(constant); - code.pos = t.pos; - return code; - } - - /** Creates a Load node. */ - public ACode Load(Tree t, ALocation location) { - ACode.Load code = ACode.Load(location); - code.pos = t.pos; - return code; - } - - /** Creates a Store node. */ - public ACode Store(Tree t, ALocation location, ACode value) { - ACode.Store code = ACode.Store(location, value); - code.pos = t.pos; - return code; - } - - /** Creates an Apply node. */ - public ACode Apply(Tree t, AFunction function, Type[] targs,ACode[] vargs){ - ACode.Apply code = ACode.Apply(function, targs, vargs); - code.pos = t.pos; - return code; - } - - /** Creates an IsAs node. */ - public ACode IsAs(Tree t, ACode value, Type type, boolean cast) { - ACode.IsAs code = ACode.IsAs(value, type, cast); - code.pos = t.pos; - return code; - } - - /** Creates an If node. */ - public ACode If(Tree t, ACode test, ACode success, ACode failure) { - ACode.If code = ACode.If(test, success, failure); - code.pos = t.pos; - return code; - } - - /** Creates a Switch node. */ - public ACode Switch(Tree t, ACode test, int[][] tags, ACode[] bodies, - ACode other) - { - ACode.Switch code = ACode.Switch(test, tags, bodies, other); - code.pos = t.pos; - return code; - } - - /** Creates a Synchronized node. */ - public ACode Synchronized(Tree t, ACode lock, ACode value) { - ACode.Synchronized code = ACode.Synchronized(lock, value); - code.pos = t.pos; - return code; - } - - /** Creates a Block node. */ - public ACode Block(Tree t, Symbol[] locals,ACode[] statements,ACode value){ - ACode.Block code = ACode.Block(locals, statements, value); - code.pos = t.pos; - return code; - } - - /** Creates a Label node. */ - public ACode Label(Tree t, Symbol label, Symbol[] locals, ACode value) { - ACode.Label code = ACode.Label(label, locals, value); - code.pos = t.pos; - return code; - } - - /** Creates a Goto node. */ - public ACode Goto(Tree t, Symbol label, ACode[] vargs) { - ACode.Goto code = ACode.Goto(label, vargs); - code.pos = t.pos; - return code; - } - - /** Creates a Return node. */ - public ACode Return(Tree t, Symbol function, ACode value) { - ACode.Return code = ACode.Return(function, value); - code.pos = t.pos; - return code; - } - - /** Creates a Throw node. */ - public ACode Throw(Tree t, ACode value) { - ACode.Throw code = ACode.Throw(value); - code.pos = t.pos; - return code; - } - - /** Creates a Drop node. */ - public ACode Drop(Tree t, ACode value, Type type) { - ACode.Drop code = ACode.Drop(value, type); - code.pos = t.pos; - return code; - } - - //######################################################################## -} diff --git a/sources/scalac/atree/ATreeFactory.java b/sources/scalac/atree/ATreeFactory.java new file mode 100644 index 0000000000..be6d0e563a --- /dev/null +++ b/sources/scalac/atree/ATreeFactory.java @@ -0,0 +1,232 @@ +/* ____ ____ ____ ____ ______ *\ +** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** +** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** +** /_____/\____/\___/\____/____/ ** +\* */ + +// $Id$ + +package scalac.atree; + +import scalac.ast.Tree; +import scalac.symtab.Symbol; +import scalac.symtab.Type; + +/** This class implements an attributed tree factory. */ +public class ATreeFactory { + + //######################################################################## + // Public Fields + + /** The unique Void node */ + public final ACode Void = ACode.Void; + + /** The unique UNIT constant */ + public final AConstant UNIT = AConstant.UNIT; + + /** The unique NULL constant */ + public final AConstant NULL = AConstant.NULL; + + /** The unique ZERO constant */ + public final AConstant ZERO = AConstant.ZERO; + + //######################################################################## + // Public Methods - Building code + + /** Builds a This node. */ + public ACode This(Tree t, Symbol clasz) { + ACode.This code = ACode.This(clasz); + code.pos = t.pos; + return code; + } + + /** Builds a Constant node. */ + public ACode Constant(Tree t, AConstant constant) { + ACode.Constant code = ACode.Constant(constant); + code.pos = t.pos; + return code; + } + + /** Builds a Load node. */ + public ACode Load(Tree t, ALocation location) { + ACode.Load code = ACode.Load(location); + code.pos = t.pos; + return code; + } + + /** Builds a Store node. */ + public ACode Store(Tree t, ALocation location, ACode value) { + ACode.Store code = ACode.Store(location, value); + code.pos = t.pos; + return code; + } + + /** Builds an Apply node. */ + public ACode Apply(Tree t, AFunction function, Type[] targs,ACode[] vargs){ + ACode.Apply code = ACode.Apply(function, targs, vargs); + code.pos = t.pos; + return code; + } + + /** Builds an IsAs node. */ + public ACode IsAs(Tree t, ACode value, Type type, boolean cast) { + ACode.IsAs code = ACode.IsAs(value, type, cast); + code.pos = t.pos; + return code; + } + + /** Builds an If node. */ + public ACode If(Tree t, ACode test, ACode success, ACode failure) { + ACode.If code = ACode.If(test, success, failure); + code.pos = t.pos; + return code; + } + + /** Builds a Switch node. */ + public ACode Switch(Tree t, ACode test, int[][] tags, ACode[] bodies, + ACode other) + { + ACode.Switch code = ACode.Switch(test, tags, bodies, other); + code.pos = t.pos; + return code; + } + + /** Builds a Synchronized node. */ + public ACode Synchronized(Tree t, ACode lock, ACode value) { + ACode.Synchronized code = ACode.Synchronized(lock, value); + code.pos = t.pos; + return code; + } + + /** Builds a Block node. */ + public ACode Block(Tree t, Symbol[] locals,ACode[] statements,ACode value){ + ACode.Block code = ACode.Block(locals, statements, value); + code.pos = t.pos; + return code; + } + + /** Builds a Label node. */ + public ACode Label(Tree t, Symbol label, Symbol[] locals, ACode value) { + ACode.Label code = ACode.Label(label, locals, value); + code.pos = t.pos; + return code; + } + + /** Builds a Goto node. */ + public ACode Goto(Tree t, Symbol label, ACode[] vargs) { + ACode.Goto code = ACode.Goto(label, vargs); + code.pos = t.pos; + return code; + } + + /** Builds a Return node. */ + public ACode Return(Tree t, Symbol function, ACode value) { + ACode.Return code = ACode.Return(function, value); + code.pos = t.pos; + return code; + } + + /** Builds a Throw node. */ + public ACode Throw(Tree t, ACode value) { + ACode.Throw code = ACode.Throw(value); + code.pos = t.pos; + return code; + } + + /** Builds a Drop node. */ + public ACode Drop(Tree t, ACode value, Type type) { + ACode.Drop code = ACode.Drop(value, type); + code.pos = t.pos; + return code; + } + + //######################################################################## + // Public Methods - Building constants + + /** Builds a BOOLEAN constant of given value. */ + public AConstant BOOLEAN(Boolean value) { + return BOOLEAN(value.booleanValue()); + } + + /** Builds a BOOLEAN constant of given value. */ + public AConstant BOOLEAN(boolean value) { + return AConstant.BOOLEAN(value); + } + + /** Builds a BYTE constant of given value. */ + public AConstant BYTE(Byte value) { + return BYTE(value.byteValue()); + } + + /** Builds a BYTE constant of given value. */ + public AConstant BYTE(byte value) { + return AConstant.BYTE(value); + } + + /** Builds a SHORT constant of given value. */ + public AConstant SHORT(Short value) { + return SHORT(value.shortValue()); + } + + /** Builds a SHORT constant of given value. */ + public AConstant SHORT(short value) { + return AConstant.SHORT(value); + } + + /** Builds a CHAR constant of given value. */ + public AConstant CHAR(Character value) { + return CHAR(value.charValue()); + } + + /** Builds a CHAR constant of given value. */ + public AConstant CHAR(char value) { + return AConstant.CHAR(value); + } + + /** Builds an INT constant of given value. */ + public AConstant INT(Integer value) { + return INT(value.intValue()); + } + + /** Builds an INT constant of given value. */ + public AConstant INT(int value) { + return AConstant.INT(value); + } + + /** Builds a LONG constant of given value. */ + public AConstant LONG(Long value) { + return LONG(value.longValue()); + } + + /** Builds a LONG constant of given value. */ + public AConstant LONG(long value) { + return AConstant.LONG(value); + } + + /** Builds a FLOAT constant of given value. */ + public AConstant FLOAT(Float value) { + return FLOAT(value.floatValue()); + } + + /** Builds a FLOAT constant of given value. */ + public AConstant FLOAT(float value) { + return AConstant.FLOAT(value); + } + + /** Builds a DOUBLE constant of given value. */ + public AConstant DOUBLE(Double value) { + return DOUBLE(value.doubleValue()); + } + + /** Builds a DOUBLE constant of given value. */ + public AConstant DOUBLE(double value) { + return AConstant.DOUBLE(value); + } + + /** Builds a STRING constant of given value. */ + public AConstant STRING(String value) { + return AConstant.STRING(value); + } + + //######################################################################## +} -- cgit v1.2.3