Esempio n. 1
0
 public ExpressionContext(JScriptBuilder builder, AssignmentExpression e)
     : this(builder)
 {
     _op = OperatorInfo.Assignment;
     Enter();
 }
Esempio n. 2
0
 public ExpressionContext(JScriptBuilder builder, BlockStatement e)
     : this(builder)
 {
     _op = OperatorInfo.Block;
 }
Esempio n. 3
0
 public ExpressionContext(JScriptBuilder builder, BinaryExpression e)
     : this(builder)
 {
     _op = OperatorInfo.GetBinary(e.Operator);
     Enter();
 }
Esempio n. 4
0
 public ExpressionContext(JScriptBuilder builder, LogicalExpression e)
     : this(builder)
 {
     _op = OperatorInfo.GetLogical(e.Operator);
     Enter();
 }
Esempio n. 5
0
 public ExpressionContext(JScriptBuilder builder, UnaryExpression e)
     : this(builder)
 {
     _op = OperatorInfo.GetUnary(e.Operator, e.Prefix);
     Enter();
 }
Esempio n. 6
0
 public ExpressionContext(JScriptBuilder builder, OperatorInfo op)
     : this(builder)
 {
     _op = op;
     Enter();
 }
Esempio n. 7
0
 public ExpressionContext(JScriptBuilder builder)
 {
     _builder = builder;
     _previous = _current.Value;
     _current.Value = this;
 }
        private void EmitScript(XmlWriter writer)
        {
            EmitScriptIncludesBefore(writer);

            var code = new JScriptWriter();
            code.WriteLine();
            code.WriteLine("// generated");
            code.Write(_scriptincludes);
            code.Write(Declarations);

            // consumed, more to come ...

            // resize handler function (unused currently)
            code.WriteLine("function docResized() ");
            code.EnterBlock();
            code.WriteLine("ResizeManager_Initialize();");
            code.Write(_resizebuilder);
            code.LeaveBlock();

            // bindings initialization
            code.WriteLine();
            code.WriteLine("function Bindings_Initialize() ");
            code.EnterBlock();
            code.WriteLine("if(window['BindingObject'] !== undefined)");
            code.EnterBlock();
            code.Write(CodeBuilder);
            code.LeaveBlock();
            code.LeaveBlock();

            // primary document ready handler
            code.WriteLine();
            code.WriteLine("docReady(function() ");
            code.EnterBlock();
            code.WriteLine("DataContext_Initialize(function() { Bindings_Initialize(); });");
            code.WriteLine("docResized();");
            code.WriteLine("DragDrop_Initialize();");
            code.LeaveBlock();
            code.WriteLine(");");


            // TraceTarget.Trace("jscript code in HTML:\n{0}\n\n", code.Text);

            writer.WriteStartElement("script");

            if (!IsOptimized)
            {

                writer.WriteRaw(code.Text);
            }
            else
            {
                Information("generating optimized code ...");
                var builder = new JScriptBuilder();
                builder.SuppressedGlobalFunctions.Add("trace");
                builder.RewriteProgram(code);
                writer.WriteRaw(builder.Text);
            }

            writer.WriteEndElement();

            // application specific initializer scripts ...
            _scriptincludes = new JScriptBuilder();
            EmitScriptIncludesAfter(writer);

            if (_scriptincludes.Text.Length > 0)
            {
                writer.WriteStartElement("script");
                writer.WriteRaw(_scriptincludes.Text);
                writer.WriteEndElement();
            }
        }
        private void EmitScriptItems(XmlWriter writer, IEnumerable<string> scriptincludes)
        {
            if (!InlineAllScript)
            {
                foreach (var include in scriptincludes)
                {
                    writer.WriteStartElement("script");
                    writer.WriteAttributeString("src", include);
                    writer.WriteString("\u00A0");
                    writer.WriteEndElement();
                }
            }
            else
            {
                var common = new JScriptWriter();

                if(null == ScriptSource)
                {
                    throw new Exception("script source required to inline scripts.");
                }

                foreach (var include in scriptincludes)
                {
                    using(var reader = new StreamReader(ScriptSource(include)))
                    {
                        Log.Trace("including script '{0}' ...", include);

                        var jscode = reader.ReadToEnd();
                        common.WriteLine(jscode);
                    }
                }

                // compactify code ...
                var compacter = new JScriptBuilder();
                compacter.IsCompact = IsCompact;
                compacter.RewriteProgram(common);

                _scriptincludes.Write(compacter);
            }
        }