Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv4856/src/bossa/syntax
Modified Files:
typecheck.nice analyse.nice TypeConstantExp.java
Removed Files:
ClassExp.java
Log Message:
Unified handling of expressions that represent classes/types under
TypeConstantExpression, which has a proper type and can be manipulated
by user code.
Index: typecheck.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typecheck.nice,v
retrieving revision 1.94
retrieving revision 1.95
diff -C2 -d -r1.94 -r1.95
*** typecheck.nice 9 Dec 2003 16:06:04 -0000 1.94
--- typecheck.nice 9 Dec 2003 17:20:14 -0000 1.95
***************
*** 654,658 ****
}
- typecheck(e@ClassExp) {}
typecheck(c@ConstantExp){}
typecheck(e@NullExp) {}
--- 654,657 ----
Index: analyse.nice
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v
retrieving revision 1.93
retrieving revision 1.94
diff -C2 -d -r1.93 -r1.94
*** analyse.nice 9 Dec 2003 16:06:04 -0000 1.93
--- analyse.nice 9 Dec 2003 17:20:15 -0000 1.94
***************
*** 326,330 ****
throw unknownIdent(notNull(pkg.locatedName()));
! return ClassExp.create(pkg, nextComponent);
}
}
--- 326,330 ----
throw unknownIdent(notNull(pkg.locatedName()));
! return TypeConstantExp.create(pkg, nextComponent);
}
}
***************
*** 520,527 ****
if (e.enableClassExp)
! return notNull(ClassExp.create(e.ident));
!
! //if (e.infix)
! //return e;
throw unknownIdent(notNull(e.ident));
--- 520,524 ----
if (e.enableClassExp)
! return notNull(TypeConstantExp.create(e.ident));
throw unknownIdent(notNull(e.ident));
Index: TypeConstantExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeConstantExp.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TypeConstantExp.java 27 Aug 2003 09:33:45 -0000 1.3
--- TypeConstantExp.java 9 Dec 2003 17:20:15 -0000 1.4
***************
*** 27,30 ****
--- 27,83 ----
}
+ private TypeConstantExp(LocatedString name, gnu.bytecode.Type type)
+ {
+ this(name);
+ this.value = type;
+ }
+
+ /**
+ @return an Expression representing ident as a type or package literal.
+ */
+ static Expression create(LocatedString ident)
+ {
+ return create(null, ident);
+ }
+
+ /**
+ @return an Expression representing [root].[name]
+ */
+ static Expression create(PackageExp root, LocatedString name)
+ {
+ String fullName = name.toString();
+ if (root != null)
+ fullName = root.name.append(".").append(fullName).toString();
+
+ mlsub.typing.TypeConstructor tc =
+ Node.getGlobalTypeScope().globalLookup(fullName, name.location());
+
+ if(tc != null)
+ {
+ gnu.bytecode.Type type = nice.tools.code.Types.javaType(tc);
+ // type might not be a class
+ // for instance if the ident was "int"
+ if (type instanceof gnu.bytecode.ClassType)
+ {
+ Expression res = new TypeConstantExp(name, type);
+ res.setLocation(root == null ? name.location() : root.location());
+ return res;
+ }
+ }
+
+ if (root != null)
+ // name has been appended to root's name
+ return root;
+
+ root = new PackageExp(fullName);
+ root.setLocation(name.location());
+ return root;
+ }
+
+ gnu.bytecode.ClassType staticClass()
+ {
+ return (gnu.bytecode.ClassType) value;
+ }
+
mlsub.typing.TypeConstructor representedType;
}
--- ClassExp.java DELETED ---
|