@@ -43,16 +43,23 @@ export default class StoryScript {
43
43
saveScope : variable . getSaveScope ( )
44
44
}
45
45
}
46
- setData ( data , object ) {
47
- variable . getGlobalScope ( object . globalScope ) ;
48
- variable . getSaveScope ( object . saveScope ) ;
46
+ setData ( object ) {
47
+ variable . setGlobalScope ( object . globalScope ) ;
48
+ variable . setSaveScope ( object . saveScope ) ;
49
49
50
- const result = parser . parse ( data ) ;
51
- const system = new IfBlock ( result ) ;
52
- this . CURRENTBLOCK = system ;
53
- this . BLOCKSTACK = [ ] ;
50
+ // must has excuted .load()
51
+ // const result = parser.parse(data);
52
+ // const system = new IfBlock(result);
53
+ // this.CURRENTBLOCK = system;
54
+ // this.BLOCKSTACK = [];
54
55
55
56
const scopes = [ object . blocks [ 0 ] . scope ] ;
57
+ variable . setScopes ( scopes ) ;
58
+ this . CURRENTBLOCK . setCurrentLine ( object . blocks [ 0 ] . currentLine ) ;
59
+
60
+ if ( object . blocks . length === 1 ) {
61
+ return true
62
+ }
56
63
57
64
for ( let i = 0 ; i < object . blocks . length ; i ++ ) {
58
65
const block = object . blocks [ i ] ;
@@ -64,24 +71,24 @@ export default class StoryScript {
64
71
case 'if' :
65
72
const ifBlock = new IfBlock ( line . blocks [ nextBlock . blockIndex ] , nextBlock . blockIndex ) ;
66
73
ifBlock . setCurrentLine ( nextBlock . currentLine ) ;
67
- scopes . push ( nextBlock . scope ) ;
68
- variable . popScope ( ) ;
74
+ variable . pushScope ( nextBlock . scope ) ;
75
+ // variable.popScope();
69
76
this . BLOCKSTACK . push ( this . CURRENTBLOCK ) ;
70
77
this . CURRENTBLOCK = ifBlock ;
71
78
break ;
72
79
case 'while' :
73
80
const whileBlock = new WhileBlock ( line . block , line . condition ) ;
74
81
whileBlock . setCurrentLine ( nextBlock . currentLine ) ;
75
- scopes . push ( nextBlock . scope ) ;
76
- variable . popScope ( ) ;
82
+ variable . pushScope ( nextBlock . scope ) ;
83
+ // variable.popScope();
77
84
this . BLOCKSTACK . push ( this . CURRENTBLOCK ) ;
78
85
this . CURRENTBLOCK = whileBlock ;
79
86
break ;
80
87
case 'foreach' :
81
88
const foreachBlock = new ForeachBlock ( line . block , line . child , line . children ) ;
82
89
foreachBlock . setCurrentLine ( nextBlock . currentLine ) ;
83
- scopes . push ( nextBlock . scope ) ;
84
- variable . popScope ( ) ;
90
+ variable . pushScope ( nextBlock . scope ) ;
91
+ // variable.popScope();
85
92
this . BLOCKSTACK . push ( this . CURRENTBLOCK ) ;
86
93
this . CURRENTBLOCK = foreachBlock ;
87
94
break ;
@@ -93,7 +100,7 @@ export default class StoryScript {
93
100
}
94
101
}
95
102
96
- variable . setScopes ( scopes ) ;
103
+ // variable.setScopes(scopes);
97
104
}
98
105
[ Symbol . iterator ] ( ) {
99
106
return this ;
0 commit comments