[Nice-commit] Nice/src/bossa/syntax userOperator.nice,NONE,1.1 customConstructor.nice,1.6,1.7 defaul
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2005-01-01 13:11:06
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31972/F:/nice/src/bossa/syntax Modified Files: customConstructor.nice defaultMethod.nice niceMethod.nice Added Files: userOperator.nice Removed Files: UserOperator.java Log Message: Converted UserOperator. Index: niceMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/niceMethod.nice,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** niceMethod.nice 31 Dec 2004 20:23:32 -0000 1.5 --- niceMethod.nice 1 Jan 2005 13:10:55 -0000 1.6 *************** *** 31,35 **** } ! isMain() { return name.toString().equals("main") && arity==1 && --- 31,35 ---- } ! public boolean isMain() { return name.toString().equals("main") && arity==1 && *************** *** 185,189 **** computeCode() = getDispatchMethod(this, module); ! getLambda() = nice.tools.code.Gen.dereference(this.getCode()); compile() {} --- 185,189 ---- computeCode() = getDispatchMethod(this, module); ! public gnu.expr.LambdaExp getLambda() = nice.tools.code.Gen.dereference(this.getCode()); compile() {} *************** *** 203,207 **** Contract contract, boolean isOverride) { ! let res = new NiceMethod(name, constraint, returnType, parameters, contract, isOverride: isOverride, returnTypeLocation: returnType.location()); return res; --- 203,207 ---- Contract contract, boolean isOverride) { ! let res = new NiceMethod(name, constraint, returnType, parameters, contract: contract, isOverride: isOverride, returnTypeLocation: returnType.location()); return res; --- NEW FILE: userOperator.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package bossa.syntax; import bossa.util.*; /** An operator whose semantics is defined by the user (i.e. not built-in). A contract can be attached to a user operator. */ public abstract class UserOperator extends MethodDeclaration { private Contract contract; private boolean resolved = false; private MonoSymbol[?] symbols = null; public Contract getContract() = contract; public MonoSymbol[?] getSymbols() = symbols; doResolve() { if (resolved) return; resolved = true; // the type must be found before this.removeChild(this.getSymbol()); this.getSymbol().doResolve(); symbols = parameters.getMonoSymbols(); if (symbols != null) { mlsub.typing.Monotype[] paramTypes = this.getArgTypes(); for (int i = 0; i < notNull(symbols).length; i++) { if (nice.tools.typing.Types.isVoid(paramTypes[i])) throw bossa.util.User.error(notNull(symbols)[i].syntacticType, "A parameter cannot have a void type"); if (notNull(symbols)[i].name != null) { notNull(symbols)[i].type = paramTypes[i]; notNull(scope).addSymbol(notNull(symbols)[i]); } } } else symbols = new MonoSymbol[0]; VarScope scope = notNull(this.scope); TypeScope typeScope = notNull(this.typeScope); super; // The contract must be resolved after the formal parameters since they // can refer to them. contract.resolve(scope, typeScope, this.getReturnType(), this.location()); } resolve() { super; // Adding the constraint in the type scope. It can be useful for // the default values of the formal parameters // (e.g. an anonymous function refering to a type parameter). let cst = this.getType().getConstraint(); if (mlsub.typing.Constraint.hasBinders(cst)) try { notNull(typeScope).addSymbols(notNull(cst).binders()); } catch (TypeScope.DuplicateName ex) { User.error(this, "Double declaration of the same type parameter"); } } innerTypecheck() { /* The body must be type-checked in a rigid context This is not done in MethodDeclaration, because it is not usefull for all subclasses. XXX: Note that this is a waste if this is a method declaration and there is no contract. The performance loss should be mesured, to see if optimisation is necessary. */ mlsub.typing.Typing.implies(); contract.typecheck(); // Set bytecode types for type variables. mlsub.typing.FunType ft = cast(this.getType().getMonotype()); nice.tools.code.Types.setBytecodeType(ft.domain()); nice.tools.code.Types.setBytecodeType(ft.codomain()); } typecheckCompiled() { /* We only need typechecking if there is a contract, to resolve overloading. We will probably be able to remove this if contracts cen be reloaded from bytecode. */ if (contract != Contract.noContract) this.typecheck(); } toString() = super + contract; } --- UserOperator.java DELETED --- Index: customConstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/customConstructor.nice,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** customConstructor.nice 20 Dec 2004 17:16:48 -0000 1.6 --- customConstructor.nice 1 Jan 2005 13:10:55 -0000 1.7 *************** *** 61,65 **** { resolveCCThis(body, this, notNull(classe)); ! body = analyseMethodBody(body, notNull(thisScope), notNull(thisTypeScope), this.getSymbols(), false); } --- 61,65 ---- { resolveCCThis(body, this, notNull(classe)); ! body = analyseMethodBody(body, notNull(thisScope), notNull(thisTypeScope), notNull(this.getSymbols()), false); } *************** *** 144,148 **** { return new CustomConstructor(new LocatedString("<init>", className.location()), ! cst, getCCReturnType(className, cst), params, Contract.noContract, className: className, body: body); --- 144,148 ---- { return new CustomConstructor(new LocatedString("<init>", className.location()), ! cst, getCCReturnType(className, cst), params, contract: Contract.noContract, className: className, body: body); Index: defaultMethod.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/defaultMethod.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** defaultMethod.nice 19 Dec 2004 19:58:28 -0000 1.3 --- defaultMethod.nice 1 Jan 2005 13:10:55 -0000 1.4 *************** *** 131,135 **** createPattern(param.getName() || new LocatedString("_", name.location())))); res.declaration = new MethodWithDefault(name, constraint, returnType, ! parameters, contract, isOverride: isOverride, implementation: res); res.addChild(res.declaration); return res; --- 131,135 ---- createPattern(param.getName() || new LocatedString("_", name.location())))); res.declaration = new MethodWithDefault(name, constraint, returnType, ! parameters, contract: contract, isOverride: isOverride, implementation: res); res.addChild(res.declaration); return res; |