[Nice-commit] Nice/src/bossa/syntax contract.nice,1.4,1.5 analyse.nice,1.130,1.131
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-03-04 01:55:31
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28507/src/bossa/syntax Modified Files: contract.nice analyse.nice Log Message: Simplified postcondition resolution by placing 'result' in the SymbolTable used for the expressions instead of the parent. Index: analyse.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/analyse.nice,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -d -r1.130 -r1.131 *** analyse.nice 22 Feb 2005 10:27:09 -0000 1.130 --- analyse.nice 4 Mar 2005 01:55:19 -0000 1.131 *************** *** 22,34 **** Statement analyse(Statement, VarScope, TypeScope, boolean mustReturnAValue); ! Expression analyse(Expression, VarScope, TypeScope); // Implementation ! Info buildInfo(VarScope varScope, TypeScope typeScope); ! buildInfo(varScope, typeScope) { let SymbolTable<mlsub.typing.TypeSymbol> t = new SymbolTable(); ! return new Info(vars: new SymbolTable(), typeVars: t, outerVarScope: varScope, outerTypeScope: typeScope, typeMap: new TypeMaper(inner: t, global: typeScope)); --- 22,35 ---- Statement analyse(Statement, VarScope, TypeScope, boolean mustReturnAValue); ! Expression analyse(Expression, VarScope, TypeScope, ! SymbolTable<VarSymbol> vars = new SymbolTable()); // Implementation ! Info buildInfo(VarScope varScope, TypeScope typeScope, ! SymbolTable<VarSymbol> vars = new SymbolTable()) { let SymbolTable<mlsub.typing.TypeSymbol> t = new SymbolTable(); ! return new Info(vars: vars, typeVars: t, outerVarScope: varScope, outerTypeScope: typeScope, typeMap: new TypeMaper(inner: t, global: typeScope)); *************** *** 63,68 **** ! analyse(Expression e, varScope, typeScope) = ! analyse(e, buildInfo(varScope, typeScope)); List<VarSymbol> lookup(VarScope scope, ?LocatedString i) --- 64,69 ---- ! analyse(Expression e, varScope, typeScope, vars) = ! analyse(e, buildInfo(varScope, typeScope, vars)); List<VarSymbol> lookup(VarScope scope, ?LocatedString i) Index: contract.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/contract.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** contract.nice 16 Jan 2005 21:51:15 -0000 1.4 --- contract.nice 4 Mar 2005 01:55:19 -0000 1.5 *************** *** 27,32 **** private StringBuffer ensureRepr = new StringBuffer("ensures "); - private ?MonoSymbol result = null; - public void addElement(Expression condition, ?Expression name, boolean precond) { --- 27,30 ---- *************** *** 58,84 **** } ! void resolve(VarScope scope, TypeScope typeScope, ! mlsub.typing.Monotype resultType, Location location) { ! pre = pre.map(Expression e => analyse(e, scope, typeScope)); if (post.isEmpty()) return; ! if (! nice.tools.typing.Types.isVoid(resultType)) ! result = new ResultMonoSymbol(new LocatedString("result", location), ! type: resultType); ! try { ! if (result != null) ! scope.addSymbol(result); ! post = post.map(Expression e => analyse(e, scope, typeScope)); ! } ! finally { ! if (result != null) ! scope.removeSymbol(result); ! } } --- 56,76 ---- } ! void resolve(VarScope scope, TypeScope typeScope, ! mlsub.typing.Monotype resultType, Location location) { ! pre = pre.map(Expression e => analyse(e, scope, typeScope)); if (post.isEmpty()) return; ! SymbolTable<VarSymbol> vars = new SymbolTable(); ! // Make 'result' a variable in the scope of the post-conditions ! if (! nice.tools.typing.Types.isVoid(resultType)) ! vars["result"] = new ResultMonoSymbol ! (new LocatedString("result", location), type: resultType); ! post = post.map(Expression e => analyse(e, scope, typeScope, vars)); } *************** *** 125,127 **** isAssignable() = false; compile() = gnu.expr.CheckContract.result; ! } \ No newline at end of file --- 117,119 ---- isAssignable() = false; compile() = gnu.expr.CheckContract.result; ! } |