Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv20107/F:/nice/src/bossa/syntax
Modified Files:
EnumDefinition.java
Log Message:
all enums extends a simple Enum class.
Index: EnumDefinition.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/EnumDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EnumDefinition.java 19 Jun 2003 15:57:23 -0000 1.1
--- EnumDefinition.java 6 Jul 2003 23:25:37 -0000 1.2
***************
*** 31,35 ****
shortName = name.toString();
classDef = ClassDefinition.makeClass
! (name,true,false, null, new ArrayList(0),null,null,null);
NiceClass impl = new NiceClass(classDef);
impl.setFields(new ArrayList(0));
--- 31,37 ----
shortName = name.toString();
classDef = ClassDefinition.makeClass
! (name,true,false, null, new ArrayList(0),
! new TypeIdent(new LocatedString("nice.lang.Enum",name.location())),
! null,null);
NiceClass impl = new NiceClass(classDef);
impl.setFields(new ArrayList(0));
***************
*** 41,49 ****
symbols = new LinkedList();
for (Iterator it = elements.iterator(); it.hasNext(); )
{
Monotype type = new TypeIdent(name);
type.nullness = Monotype.absent;
! symbols.add(new EnumSymbol(name, (LocatedString)it.next(), type));
}
addChildren(symbols);
--- 43,53 ----
symbols = new LinkedList();
+ int ord = 0;
for (Iterator it = elements.iterator(); it.hasNext(); )
{
Monotype type = new TypeIdent(name);
type.nullness = Monotype.absent;
! symbols.add(new EnumSymbol(name, (LocatedString)it.next(), type, ord));
! ord++;
}
addChildren(symbols);
***************
*** 53,60 ****
class EnumSymbol extends MonoSymbol
{
! EnumSymbol(LocatedString enumName, LocatedString name, Monotype type)
{
super(name, type);
! this.value = new NewExp(new TypeIdent(enumName), Arguments.noArguments());
}
--- 57,71 ----
class EnumSymbol extends MonoSymbol
{
! EnumSymbol(LocatedString enumName, LocatedString name, Monotype type, int ordinal)
{
super(name, type);
! List args = new ArrayList(2);
! args.add(new Arguments.Argument(new StringConstantExp(name.toString()),
! new LocatedString("name",name.location)));
! Integer val = new Integer(ordinal);
! args.add(new Arguments.Argument(new ConstantExp(PrimitiveType.intTC, val,
! val.toString(), name.location()),
! new LocatedString("ordinal",name.location)));
! this.value = new NewExp(new TypeIdent(enumName), new Arguments(args));
}
|