Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

demo script null bug

  • Loading branch information...
commit 69a560737675890bda443485a8e82a148004f1c0 1 parent 2e54a88
@hochang hochang authored
View
7 modules/compiler/lib/compiler.js
@@ -83,7 +83,7 @@ function plan(compiled) {
}
else if (line.type === 'try') {
//dependsOn are the lines in try clause
- divescope(line.tryClause, line);
+ divescope(line.dependsOn, line);
_.each(line.catchClause, function(mycatch, k){
divescope(mycatch.lines, line);
});
@@ -130,7 +130,7 @@ function plan(compiled) {
}
else if (line.type === 'try') {
//dependsOn are the lines in try clause
- divescope(line.tryClause, line);
+ divescope(line.dependsOn, line);
_.each(line.catchClause, function(mycatch, k){
divescope(mycatch.lines, line);
});
@@ -316,7 +316,8 @@ function walk(line, symbols) {
});
break;
case 'try':
- _.each(line.tryClause, function(tryline){
+ _.each(line.dependsOn, function(tryline){
+ addListener(tryline, line);
walk(tryline, symbols);
});
_.each(line.catchClause, function(currentcatch){
View
9 modules/compiler/lib/peg/ql.js
@@ -777,13 +777,18 @@ module.exports = (function(){
}
}
}
+ var catchConds = [];
+ for(var i = 0; i < catchClause.length; i++){
+ catchConds.push(catchClause[i].condition);
+ }
return {
id : id++,
line : line,
type : 'try',
- tryClause : tryClause,
+ dependsOn : tryClause.concat(catchConds),
catchClause : catchClause,
- finallyClause : finallyClause || undefined
+ finallyClause : finallyClause || undefined,
+ lock : false
}
})(pos0.offset, pos0.line, pos0.column, result0[4], result0[7], result0[8]);
}
View
9 modules/compiler/pegs/ql.peg
@@ -469,13 +469,18 @@ TryClause = 'try' insig '{' insig tryClause:TryCrlf+ insig '}' catchClause:Catch
}
}
}
+ var catchConds = [];
+ for(var i = 0; i < catchClause.length; i++){
+ catchConds.push(catchClause[i].condition);
+ }
return {
id : id++,
line : line,
type : 'try',
- tryClause : tryClause,
+ dependsOn : tryClause.concat(catchConds),
catchClause : catchClause,
- finallyClause : finallyClause || undefined
+ finallyClause : finallyClause || undefined,
+ lock : false
}
}
View
2  modules/compiler/test/scope-test.js
@@ -27,7 +27,7 @@ module.exports = {
}\n\
finally {select * from bbb}";
var statement = compiler.compile(q);
- test.equals(statement.rhs.tryClause.length, 2);
+ test.equals(statement.rhs.dependsOn.length, 2);
test.equals(statement.rhs.catchClause.length, 1);
test.equals(statement.rhs.catchClause[0].condition.values, 'asdf');
test.equals(statement.rhs.catchClause[0].condition.logic, 'normal');
View
3  modules/console/public/scripts/console.js
@@ -425,6 +425,8 @@ $(document).ready(function() {
})
emitter.on('script-done', function (data) {
markers.push(editor.setMarker(data.line - 1, data.elapsed + ' ms', 'green'));
+ delPic();
+ $('#step').hide();
});
}
@@ -438,6 +440,7 @@ $(document).ready(function() {
};
socket.send(JSON.stringify(packet));
delPic();
+ $('#step').hide();
}
function delPic(){
View
43 modules/engine/lib/engine.js
@@ -307,7 +307,7 @@ Engine.prototype.execute = function() {
});
break;
case 'try':
- _.each(statement.tryClause, function(line){
+ _.each(statement.dependsOn, function(line){
init(line);
});
_.each(statement.catchClause, function(currentcatch){
@@ -355,7 +355,7 @@ Engine.prototype.execute = function() {
execState[statement.id].state = eventTypes.STATEMENT_SUCCESS;
switch(statement.type){
case 'try':
- _.each(statement.tryClause, function(tryline){//these are just lines within try{}
+ _.each(statement.dependsOn, function(tryline){//these are just lines within try{}
skipVar(tryline);
});
_.each(statement.catchClause, function(mycatch,k){
@@ -383,6 +383,9 @@ Engine.prototype.execute = function() {
_.each(statement.listeners, function(listener) {
execState[listener.id].count--;
if (!(listener.fbhold)){
+ if(listener.type === 'try'){
+ listener.lock = false;
+ }
return listener;
}
});
@@ -434,16 +437,40 @@ Engine.prototype.execute = function() {
if(skip) {
return;
}
- if(statement.scope && execState[statement.scope.id].state === eventTypes.STATEMENT_WAITING) {
+ if(statement.scope && execState[statement.scope.id].state === eventTypes.STATEMENT_WAITING &&
+ (statement.scope.type !== 'try' || !statement.scope.lock)) {
sweep(statement.scope);
return;
}
+ if(statement.type === 'try'){
+ var dependsDone = _.all(statement.dependsOn, function(tryline){
+ return execState[tryline.id].state === 'statement-success';
+ });
+ if(!dependsDone){
+ //block revisit try from lines in this scope.
+ statement.lock = true;
+ }
+ }
_.each(statement.dependsOn, function(dependency) {
if(execState[dependency.id].state === eventTypes.STATEMENT_WAITING) {
// Exec the dependency
sweep(dependency);
}
});
+
+ /*if(statement.type === 'try'){
+ var dependsDone = _.all(statement.dependsOn, function(tryline){
+ return execState[tryline.id].state === 'statement-success';
+ })
+ if(!dependsDone){
+ //block revisit try from lines in this scope.
+ statement.lock = true;
+ _.each(statement.dependsOn, function(tryline){
+ sweep(tryline);
+ });
+ return;
+ }
+ } */
if(statement.rhs) {
_.each(statement.rhs.dependsOn, function(dependency) {
if(execState[dependency.id].state === eventTypes.STATEMENT_WAITING) {
@@ -457,17 +484,12 @@ Engine.prototype.execute = function() {
}
var todo = statement.rhs || statement,
- scopeDone = !todo.scope || execState[todo.scope.id].state === eventTypes.STATEMENT_SUCCESS;
+ scopeDone = !todo.scope || execState[todo.scope.id].state === eventTypes.STATEMENT_SUCCESS || (todo.scope.lock && _.contains(todo.scope.dependsOn, todo));
if(execState[todo.id].state === eventTypes.STATEMENT_WAITING && // Don't try if in-flight
execState[todo.id].count === 0 &&
scopeDone) {
execState[todo.id].state = eventTypes.STATEMENT_IN_FLIGHT;
- if(todo.type === 'try'){
- _.each(todo.tryClause, function(tryline){
- sweep(tryline);
- });
- }
if (emitterID && !step1) {
// only used for debugger
unexecuted.push(statement);
@@ -532,6 +554,9 @@ Engine.prototype.execute = function() {
_.each(todo.listeners, function(listener) {
execState[listener.id].count--;
if (!(listener.fbhold)){
+ if(listener.type === 'try'){
+ listener.lock = false;
+ }
sweep(listener);
}
});
View
28 modules/engine/test/scope-test.js
@@ -230,3 +230,31 @@ module.exports['ifelse-nested'] = function(test) {
}
}});
};
+
+module.exports['ifelse-nested'] = function(test) {
+ var q = 'foo = true \
+ bar = false\
+ try{\
+ mycond = select * from bar\
+ if(mycond){\
+ result4 = "hello world";\
+ }else{\
+ NoLanguagePack = true\
+ throw (NoLanguagePack)\
+ } \
+ }\
+ catch (NoLanguagePack){\
+ result3 = "not found"\
+ }\
+ return result4 || result3';
+ engine.exec({script: q, cb: function(err, result) {
+ if(err) {
+ test.fail('got error: ' + err.stack);
+ test.done();
+ }
+ else {
+ test.equals(result.body, "not found");
+ test.done();
+ }
+ }});
+}
Please sign in to comment.
Something went wrong with that request. Please try again.