[Nice-commit] Nice/src/bossa/syntax Macro.java,NONE,1.1 VarSymbol.java,1.27,1.28 TupleExp.java,1.16,
Brought to you by:
bonniot
|
From: <bo...@us...> - 2003-04-30 18:55:38
|
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1:/tmp/cvs-serv24458/src/bossa/syntax
Modified Files:
VarSymbol.java TupleExp.java SymbolExp.java
OverloadedSymbolExp.java MethodDeclaration.java
InlinedMethod.java FormalParameters.java Expression.java
CallExp.java
Added Files:
Macro.java
Log Message:
Implemented handling of numeric values as arrays of bits: read access for
all values, and write access for numeric variables and fields.
The implementation uses the new bossa.syntax.Macro interface, which allows
inlined methods to do semantic checks on their arguments.
--- NEW FILE: Macro.java ---
/**************************************************************************/
/* N I C E */
/* A high-level object-oriented research language */
/* (c) Daniel Bonniot 2003 */
/* */
/* 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;
/**
A macro.
This interface should be implemented by classes that are used
to implement inlined methods, and that need to do some semantic checking
on their actual arguments.
@version $Date: 2003/04/30 18:55:31 $
@author Daniel Bonniot (bo...@us...)
*/
public interface Macro extends gnu.expr.Inlineable
{
/**
For each call site, this method is called with the actual arguments
of the macro. This can be used to check special requirements on the
arguments that could not be expressed in the type of the macro.
For instance, it might be necessary to check that a certain argument
is assignable if it is modified by the macro.
*/
void checkSpecialRequirements(Expression[] arguments);
}
Index: VarSymbol.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/VarSymbol.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** VarSymbol.java 2 Sep 2002 11:46:51 -0000 1.27
--- VarSymbol.java 30 Apr 2003 18:55:29 -0000 1.28
***************
*** 54,57 ****
--- 54,62 ----
}
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ // Do nothing by default.
+ }
+
abstract Polytype getType();
Index: TupleExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TupleExp.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** TupleExp.java 17 Mar 2003 20:11:43 -0000 1.16
--- TupleExp.java 30 Apr 2003 18:55:30 -0000 1.17
***************
*** 47,51 ****
****************************************************************/
! boolean isAssignable()
{
for (int i = 0; i < expressions.length; i++)
--- 47,51 ----
****************************************************************/
! public boolean isAssignable()
{
for (int i = 0; i < expressions.length; i++)
Index: SymbolExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/SymbolExp.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** SymbolExp.java 12 Mar 2003 03:32:01 -0000 1.31
--- SymbolExp.java 30 Apr 2003 18:55:30 -0000 1.32
***************
*** 31,35 ****
}
! boolean isAssignable()
{
return symbol.isAssignable();
--- 31,35 ----
}
! public boolean isAssignable()
{
return symbol.isAssignable();
***************
*** 39,42 ****
--- 39,47 ----
{
return symbol.getFieldAccessMethod();
+ }
+
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ symbol.checkSpecialRequirements(arguments);
}
Index: OverloadedSymbolExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/OverloadedSymbolExp.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** OverloadedSymbolExp.java 24 Apr 2003 12:21:26 -0000 1.51
--- OverloadedSymbolExp.java 30 Apr 2003 18:55:30 -0000 1.52
***************
*** 65,69 ****
}
! boolean isAssignable()
{
Internal.error("Overloading resolution should be done before this.");
--- 65,69 ----
}
! public boolean isAssignable()
{
Internal.error("Overloading resolution should be done before this.");
Index: MethodDeclaration.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodDeclaration.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** MethodDeclaration.java 18 Apr 2003 14:50:23 -0000 1.38
--- MethodDeclaration.java 30 Apr 2003 18:55:31 -0000 1.39
***************
*** 221,224 ****
--- 221,229 ----
public boolean isFieldAccess() { return false; }
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ // Do nothing by default.
+ }
+
/**
@return true if this method is the 'main' of the program
***************
*** 260,263 ****
--- 265,273 ----
else
return null;
+ }
+
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ getDefinition().checkSpecialRequirements(arguments);
}
Index: InlinedMethod.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/InlinedMethod.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** InlinedMethod.java 22 Nov 2001 15:08:50 -0000 1.10
--- InlinedMethod.java 30 Apr 2003 18:55:31 -0000 1.11
***************
*** 103,107 ****
" cannot be inlined, but will be called anyway");
! return new gnu.expr.QuoteExp((gnu.mapping.Procedure) o);
}
--- 103,108 ----
" cannot be inlined, but will be called anyway");
! this.procedure = (gnu.mapping.Procedure) o;
! return new gnu.expr.QuoteExp(procedure);
}
***************
*** 109,112 ****
--- 110,121 ----
private LocatedString inlineProcedure;
private String parameter;
+ private gnu.mapping.Procedure procedure;
+
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ getCode();
+ if (procedure instanceof bossa.syntax.Macro)
+ ((Macro) procedure).checkSpecialRequirements(arguments);
+ }
public void printInterface(java.io.PrintWriter s)
Index: FormalParameters.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/FormalParameters.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** FormalParameters.java 30 Apr 2003 17:26:49 -0000 1.22
--- FormalParameters.java 30 Apr 2003 18:55:31 -0000 1.23
***************
*** 124,128 ****
}
! boolean isAssignable () { return false; }
public gnu.expr.Expression compile ()
--- 124,128 ----
}
! public boolean isAssignable () { return false; }
public gnu.expr.Expression compile ()
Index: Expression.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Expression.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** Expression.java 30 Apr 2003 17:45:17 -0000 1.45
--- Expression.java 30 Apr 2003 18:55:31 -0000 1.46
***************
*** 41,45 ****
/** @return true iff this expression can be assigned a value. */
! boolean isAssignable()
{
return false;
--- 41,45 ----
/** @return true iff this expression can be assigned a value. */
! public boolean isAssignable()
{
return false;
***************
*** 186,189 ****
--- 186,194 ----
return res;
+ }
+
+ void checkSpecialRequirements(Expression[] arguments)
+ {
+ // Do nothing by default.
}
Index: CallExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/CallExp.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** CallExp.java 30 Apr 2003 17:20:43 -0000 1.75
--- CallExp.java 30 Apr 2003 18:55:32 -0000 1.76
***************
*** 244,247 ****
--- 244,249 ----
function = function.resolveOverloading(this);
+
+ function.checkSpecialRequirements(arguments.computedExpressions);
}
***************
*** 287,291 ****
private Polytype instanciatedDomain;
! boolean isAssignable()
{
resolveOverloading();
--- 289,293 ----
private Polytype instanciatedDomain;
! public boolean isAssignable()
{
resolveOverloading();
|