Revision: 1936
http://svn.sourceforge.net/vexi/?rev=1936&view=rev
Author: mkpg2
Date: 2007-07-07 05:02:56 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Devl feature. Check for dodgy traps (no explicit cascades or returns)
Modified Paths:
--------------
core/trunk/org.ibex.js/src/org/ibex/js/JS.jpp
core/trunk/org.ibex.js/src/org/ibex/js/JSFunction.java
core/trunk/org.ibex.js/src/org/ibex/js/Lexer.jpp
core/trunk/org.ibex.js/src/org/ibex/js/Parser.java
Modified: core/trunk/org.ibex.js/src/org/ibex/js/JS.jpp
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/JS.jpp 2007-07-06 17:30:55 UTC
(rev 1935)
+++ core/trunk/org.ibex.js/src/org/ibex/js/JS.jpp 2007-07-07 12:02:56 UTC
(rev 1936)
@@ -294,6 +294,10 @@
}
public void addTrap(JS key, JS f) throws JSExn {
+ if (f instanceof JSFunction && !((JSFunction)f).isValidTrap()){
+ JSU.warn("Trap function has no explicit
cascade/return");
+ }
+
if (f instanceof JSFunction && (f.getFormalArgs() == null ||
f.getFormalArgs().length > 1))
throw new JSExn("traps must take either one argument (write)
or no arguments (read)");
for (Trap t = (Trap)super.get(key, 1); t != null; t = t.next())
Modified: core/trunk/org.ibex.js/src/org/ibex/js/JSFunction.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/JSFunction.java 2007-07-06
17:30:55 UTC (rev 1935)
+++ core/trunk/org.ibex.js/src/org/ibex/js/JSFunction.java 2007-07-07
12:02:56 UTC (rev 1936)
@@ -7,7 +7,13 @@
/** A JavaScript function, compiled into bytecode */
class JSFunction extends JS.Immutable implements ByteCodes, Tokens{
private static final String[] emptyFormalArgs = new String[0];
-
+
+ private boolean validTrap = false;
+ public void setValidTrap(){
+ validTrap=true;
+ }
+ public boolean isValidTrap(){return validTrap;}
+
// Fields and Accessors ///////////////////////////////////////////////
String[] formalArgs; ///< the names of the formal arguments
@@ -27,6 +33,7 @@
public JSFunction _cloneWithNewParentScope(Scope s) {
JSFunction ret = new JSFunction(sourceName, firstLine, s);
+ ret.validTrap = this.validTrap;
// Reuse the same op, arg, line, and size variables for the new
"instance" of the function
// NOTE: Neither *this* function nor the new function should be
modified after this call
ret.op = this.op;
Modified: core/trunk/org.ibex.js/src/org/ibex/js/Lexer.jpp
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/Lexer.jpp 2007-07-06 17:30:55 UTC
(rev 1935)
+++ core/trunk/org.ibex.js/src/org/ibex/js/Lexer.jpp 2007-07-07 12:02:56 UTC
(rev 1936)
@@ -407,9 +407,13 @@
// remember the ln of every pushedBack token (??). Not inviting edge
cases
// and doing it anyway.
parserLine = pushBackLines[pushBackDepth];
+ if(op==RETURN ||op==CASCADE ) validTrap();
return op;
}
+ void validTrap(){}
+
+
class LexerException extends SourceException {
public LexerException(String s) { super(s,Lexer.this.sourceName,
Lexer.this.line ); }
public String getMessageSig() {
Modified: core/trunk/org.ibex.js/src/org/ibex/js/Parser.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/Parser.java 2007-07-06 17:30:55 UTC
(rev 1935)
+++ core/trunk/org.ibex.js/src/org/ibex/js/Parser.java 2007-07-07 12:02:56 UTC
(rev 1936)
@@ -229,6 +229,10 @@
b.set(si.newScopeInsn,JSU.N((si.base<<16)|((si.end-si.base)<<0)));
}
+ void validTrap() {
+ JSFunction f = ((ScopeInfo)scopeStack.peek()).jsfunc;
+ f.setValidTrap();
+ }
// Parsing Logic /////////////////////////////////////////////////////////
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn