예제 #1
0
 public ExpressionContext(JScriptBuilder builder)
 {
     _builder = builder;
     _previous = _current.Value;
     _current.Value = this;
 }
예제 #2
0
        private void EmitBlockStatement(BlockStatement block)
        {
            EnterBlock();

            using (var ex = new ExpressionContext(this, block))
            {

                foreach (var s in block.Body)
                {
                    Emit(s);
                }
            }

            LeaveBlock();
        }
예제 #3
0
        private void EmitFunctionDeclaration(FunctionDeclaration fdecl)
        {
            WriteSeparator();
            TranslateFunctionHeader(fdecl, fdecl.Parameters);

            using (var ec = new ExpressionContext(this, OperatorInfo.Body))
            {
                Emit(fdecl.Body);
            }
        }
예제 #4
0
        private void EmitExpressionStatement(ExpressionStatement s)
        {
            using (var ec = new ExpressionContext(this, OperatorInfo.Body))
            {
                if (s.Expression is CallExpression)
                {
                    var call = s.Expression as CallExpression;
                    if (call.Callee is FunctionExpression)
                    {
                        // group around function expression (function(){}());
                        ec.BeginGroup();
                    }
                }

                Emit(s.Expression);
            }

            Write(";");
        }
예제 #5
0
 private void EmitAssignmentExpression(AssignmentExpression e)
 {
     using (var ec = new ExpressionContext(this, e))
     {
         Emit(e.Left);
         Write(" " + TranslateAssignmentOperator(e.Operator) + " ");
         Emit(e.Right);
     }
 }
예제 #6
0
 private void EmitLogicalExpression(LogicalExpression e)
 {
     using (var ec = new ExpressionContext(this, e))
     {
         Emit(e.Left);
         Write(" " + ec.Token + " ");
         Emit(e.Right);
     }
 }
예제 #7
0
 private void EmitUpdateExpression(UpdateExpression e)
 {
     using (var ec = new ExpressionContext(this, e))
     {
         if (e.Prefix)
         {
             Write(ec.Token);
             Emit(e.Argument);
         }
         else
         {
             Emit(e.Argument);
             Write(ec.Token);
         }
     }
 }
예제 #8
0
 private void EmitUnaryExpression(UnaryExpression e)
 {
     if (e.Prefix)
     {
         using (var ec = new Wpf2Html5.Builder.ExpressionContext(this, e))
         {
             Write(ec.Token);
             Emit(e.Argument);
         }
     }
     else
     {
         using (var ec = new Wpf2Html5.Builder.ExpressionContext(this, e))
         {
             Emit(e.Argument);
             Write(ec.Token);
         }
     }
 }