Beispiel #1
0
 public static JsBlock Add(this JsBlock block, JsStatement st)
 {
     if (block.Statements == null)
         block.Statements = new List<JsStatement>();
     block.Statements.Add(st);
     return block;
 }
Beispiel #2
0
 public static JsFunction Add(this JsFunction func, JsStatement st)
 {
     if (func.Block == null)
         func.Block = new JsBlock();
     if (func.Block.Statements == null)
         func.Block.Statements = new List<JsStatement>();
     func.Block.Statements.Add(st);
     return func;
 }
Beispiel #3
0
        object ProcessStatement(JsStatement node)
        {
            if (node is JsYieldReturnStatement)
            {
                var st2 = (JsYieldReturnStatement)node;
                YieldReturnInCurrentStep(st2.Expression);
                BeginNewStep();
                return null;
            }
            else if (node is JsVariableDeclarationStatement)
            {
                var node2 = (JsVariableDeclarationStatement)node;
                var decl = node2.Declaration.Declarators.Single();
                var node3 = Js.This().Member(decl.Name).Assign(decl.Initializer).Statement();
                AddToCurrentStep(node3);
                return null;
            }

            if (node is JsBlock)
            {
                //BeginNewStep();
                var block = (JsBlock)node;
                foreach (var st in block.Statements)
                {
                    ProcessStatement(st);
                }
            }
            else if (node is JsWhileStatement)
            {
                BeginNewStep();
                var st = (JsWhileStatement)node;
                ProcessStatement(st.Statement);
                var step = Steps.Last();
                st.Statement = new JsBlock { Statements = step.Statements.ToList() };
                step.Statements.Clear();
                step.Statements.Add(st);
                BeginNewStep();
            }
            else
            {
                AddToCurrentStep(node);
            }
            return node;
        }
 protected virtual void _visit( JsStatement node )
 {
     throw new NotImplementedException( "JsStatement" );
 }
Beispiel #5
0
 void AddToCurrentStep(JsStatement st)
 {
     Steps.Last().Statements.Add(st);
 }
 protected override void _visit(JsStatement node)
 {
     if (node != null)
     {
         // TODO: JsStatement?
     }
 }
Beispiel #7
0
 public static JsWhileStatement While(JsExpression condition, JsStatement statement = null)
 {
     return new JsWhileStatement { Condition = condition, Statement = statement };
 }
Beispiel #8
0
 public static JsIfStatement Then(this JsIfStatement ifStatement, JsStatement thenStatement)
 {
     ifStatement.IfStatement = thenStatement;
     return ifStatement;
 }
Beispiel #9
0
 public static JsIfStatement If(JsExpression condition, JsStatement ifStatement = null, JsStatement elseStatement = null)
 {
     return new JsIfStatement { Condition = condition, IfStatement = ifStatement, ElseStatement = elseStatement };
 }
Beispiel #10
0
 public static JsIfStatement Else(this JsIfStatement ifStatement, JsStatement elseStatement)
 {
     ifStatement.ElseStatement = elseStatement;
     return ifStatement;
 }