Inheritance: IExpression
Ejemplo n.º 1
0
        public override void Visit(BlockExpression expression)
        {
            Block newblock = new Block(null, this.block);

            // TODO Review is the copy of argument and local names is needed
            foreach (var parname in this.block.ParameterNames)
                newblock.CompileArgument(parname);

            foreach (var locname in this.block.LocalNames)
                newblock.CompileLocal(locname);

            if (expression.ParameterNames != null)
                foreach (var parname in expression.ParameterNames)
                    newblock.CompileArgument(parname);

            if (expression.LocalVariables != null)
                foreach (var locname in expression.LocalVariables)
                    newblock.CompileLocal(locname);

            var compiler = new BytecodeCompiler(newblock);
            compiler.Visit(expression.Body);
            this.block.CompileGetBlock(newblock);
        }
Ejemplo n.º 2
0
 public abstract void Visit(BlockExpression expression);
Ejemplo n.º 3
0
        public override void Visit(BlockExpression expression)
        {
            // TODO block with parameters, return
            this.writer.Write("function(");
            int npars = 0;
            
            foreach (string parname in expression.ParameterNames)
            {
                if (npars > 0)
                    this.writer.Write(", ");
                this.writer.Write(parname);
                npars++;
            }

            this.writer.WriteLineStart(") {");

            foreach (string locname in expression.LocalVariables)
                this.writer.WriteLine(string.Format("var {0} = null;", locname));

            bool previousInBlock = this.inBlock;

            try
            {
                this.inBlock = true;
                this.Visit(expression.Body);
            }
            finally
            {
                this.inBlock = previousInBlock;
            }

            this.writer.WriteLineEnd("}");
        }