Nice/src/bossa/syntax contract.nice,1.4,1.5 analyse.nice,1.130,1.131

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
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;
! }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.