[Nice-commit] Nice/src/bossa/syntax Pattern.java,1.45,1.46 MethodBodyDefinition.java,1.118,1.119
Brought to you by:
bonniot
|
From: <bo...@us...> - 2003-04-28 18:10:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv24896/src/bossa/syntax
Modified Files:
Pattern.java MethodBodyDefinition.java
Log Message:
Parameter type naming is now done on the tag only, as this is the only
interesting part.
Therefore, the part after : is always a type constructor variable, so we
don't need to declare anything before; it is declared there. So we remove
the syntax to declare additional type parameters in front of the method
implementation.
Index: Pattern.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** Pattern.java 16 Apr 2003 18:38:58 -0000 1.45
--- Pattern.java 28 Apr 2003 18:10:29 -0000 1.46
***************
*** 50,61 ****
It must be a super-class of <code>tc</code>.
It is only used for overloading resolution, not at runtime.
! @param type a monotype that must be equal to
! the argument's runtime type. This is usefull to introduce
! a type constructor variable with the exact type of the argument.
*/
public Pattern(LocatedString name,
TypeIdent tc, Expression atValue,
boolean exactlyAt, TypeIdent additional,
! bossa.syntax.Monotype type,
Location location)
{
--- 50,60 ----
It must be a super-class of <code>tc</code>.
It is only used for overloading resolution, not at runtime.
! @param runtimeTC a type constructor that will be bound to
! the argument's runtime class.
*/
public Pattern(LocatedString name,
TypeIdent tc, Expression atValue,
boolean exactlyAt, TypeIdent additional,
! TypeConstructor runtimeTC,
Location location)
{
***************
*** 63,67 ****
this.typeConstructor = tc;
this.additional = additional;
! this.type = type;
this.atValue = atValue;
this.exactlyAt = exactlyAt;
--- 62,66 ----
this.typeConstructor = tc;
this.additional = additional;
! this.runtimeTC = runtimeTC;
this.atValue = atValue;
this.exactlyAt = exactlyAt;
***************
*** 148,154 ****
! final mlsub.typing.Monotype getType()
{
! return t;
}
--- 147,153 ----
! final TypeConstructor getRuntimeTC()
{
! return runtimeTC;
}
***************
*** 184,196 ****
}
- void resolveType(TypeScope scope)
- {
- if(type!=null)
- {
- t = type.resolve(scope);
- type = null;
- }
- }
-
static void resolveTC(TypeScope scope, Pattern[] patterns)
{
--- 183,186 ----
***************
*** 199,208 ****
}
- static void resolveType(TypeScope scope, Pattern[] patterns)
- {
- for(int i = 0; i < patterns.length; i++)
- patterns[i].resolveType(scope);
- }
-
/****************************************************************
* Type checking
--- 189,192 ----
***************
*** 583,588 ****
public TypeConstructor tc;
TypeConstructor tc2;
! private bossa.syntax.Monotype type;
! private mlsub.typing.Monotype t;
// The class constraint verified by this pattern.
--- 567,571 ----
public TypeConstructor tc;
TypeConstructor tc2;
! private TypeConstructor runtimeTC;
// The class constraint verified by this pattern.
Index: MethodBodyDefinition.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v
retrieving revision 1.118
retrieving revision 1.119
diff -C2 -d -r1.118 -r1.119
*** MethodBodyDefinition.java 25 Apr 2003 17:21:26 -0000 1.118
--- MethodBodyDefinition.java 28 Apr 2003 18:10:30 -0000 1.119
***************
*** 51,55 ****
LocatedString name,
Collection binders,
- List newTypeVars,
List formals,
Statement body)
--- 51,54 ----
***************
*** 62,68 ****
this.body = body;
this.declaration = null;
- if (newTypeVars != null)
- this.newTypeVars = (TypeConstructor[])
- newTypeVars.toArray(new TypeConstructor[newTypeVars.size()]);
this.insideClass = container != null ||
--- 61,64 ----
***************
*** 107,124 ****
Pattern p = names[tn];
! MonotypeVar type;
! if (p.name == null)
! // anonymous pattern
! type = new MonotypeVar("anonymous argument " + tn);
else
- // XXX optimize using this:
- // type = new MonotypeVar("type(" + p.name + ")<" + types[tn]);
{
! LocatedString typeName;
! typeName = p.name.cloneLS();
! typeName.prepend("type(");
! typeName.append(")<" + types[tn]);
! type = new MonotypeVar(typeName.toString());
}
--- 103,132 ----
Pattern p = names[tn];
! Monotype type;
! if (p.getRuntimeTC() != null)
! {
! AtomicKind v = p.tc.variance;
! p.getRuntimeTC().setVariance(v);
! type = new mlsub.typing.MonotypeConstructor(p.getRuntimeTC(), mlsub.typing.MonotypeVar.news(v.arity()));
! type.setKind(v);
!
! type = bossa.syntax.Monotype.sure(type);
! }
else
{
! if (p.name == null)
! // anonymous pattern
! type = new MonotypeVar("anonymous argument " + tn);
! else
! // XXX optimize using this:
! // type = new MonotypeVar("type(" + p.name + ")<" + types[tn]);
! {
! LocatedString typeName;
! typeName = p.name.cloneLS();
! typeName.prepend("type(");
! typeName.append(")<" + types[tn]);
! type = new MonotypeVar(typeName.toString());
! }
}
***************
*** 291,304 ****
}
- if (newTypeVars != null)
try{
! typeScope.addSymbols(newTypeVars);
}
catch(TypeScope.DuplicateName e) {
User.error(this, e);
}
-
- // We can resolve now
- Pattern.resolveType(this.typeScope, formals);
}
--- 299,313 ----
}
try{
! for(int n = 0; n < formals.length; n++)
! {
! TypeConstructor tc = formals[n].getRuntimeTC();
! if (tc != null)
! typeScope.addSymbol(tc);
! }
}
catch(TypeScope.DuplicateName e) {
User.error(this, e);
}
}
***************
*** 354,378 ****
for(int n = 0; n < formals.length; n++)
{
! Pattern pat = formals[n];
! Monotype type = pat.getType();
! if (type == null)
Typing.introduce(monotypes[n]);
else
! {
! parameters[n].type = monotypes[n] = type;
!
! // We need to find the variance of the constructor.
! // This is the only case where a type constructor is created
! // without a known variance. But we can get it easily from the
! // pattern.
! TypeConstructor tc = Types.rawType(type).head();
! if (tc != null && tc.variance == null)
! tc.setVariance(pat.tc.variance);
! }
}
- if (newTypeVars != null)
- Typing.introduce(newTypeVars);
-
// The arguments are specialized by the patterns
try{
--- 363,373 ----
for(int n = 0; n < formals.length; n++)
{
! TypeConstructor runtimeTC = formals[n].getRuntimeTC();
! if (runtimeTC == null)
Typing.introduce(monotypes[n]);
else
! Typing.introduce(runtimeTC);
}
// The arguments are specialized by the patterns
try{
***************
*** 543,547 ****
private Pattern[] formals;
Collection /* of LocatedString */ binders; // Null if type parameters are not bound
- private TypeConstructor[] newTypeVars;
private Statement body;
private boolean insideClass;
--- 538,541 ----
|