AjTalk.Compilers.Vm.BytecodeCompiler.Visit C# (CSharp) Метод

Visit() публичный Метод

public Visit ( MessageExpression expression ) : void
expression AjTalk.Model.MessageExpression
Результат void
        public override void Visit(MessageExpression expression)
        {
            int initialposition = this.block.Bytecodes == null ? 0 : this.block.Bytecodes.Length;

            expression.Target.Visit(this);

            int condposition = this.block.Bytecodes == null ? 0 : this.block.Bytecodes.Length;

            foreach (var arg in expression.Arguments)
                arg.Visit(this);

            if (expression.Selector == "whileTrue:" || expression.Selector == "whileFalse:")
            {
                this.block.CompileByteCode(ByteCode.Value);
                this.block.CompileByteCode(ByteCode.Pop);
                this.block.CompileJumpByteCode(ByteCode.Jump, (short)initialposition);
                this.block.CompileInsert(condposition, 4);
                int finalposition = this.block.Bytecodes.Length;
                this.block.CompileBlockJumpByteCodeAt(expression.Selector == "whileFalse:" ? ByteCode.JumpIfTrue : ByteCode.JumpIfFalse, (short)finalposition, condposition);
            }
            else if (expression.Selector == "ifFalse:" || expression.Selector == "ifTrue:")
            {
                this.block.CompileByteCode(ByteCode.Value);
                this.block.CompileInsert(condposition, 7);
                this.block.CompileJumpByteCodeAt(expression.Selector == "ifFalse:" ? ByteCode.JumpIfFalse : ByteCode.JumpIfTrue, (short)(condposition + 7), condposition);
                this.block.CompileByteCodeAt(ByteCode.GetNil, condposition + 3);
                int finalposition = this.block.Bytecodes.Length;
                this.block.CompileJumpByteCodeAt(ByteCode.Jump, (short)finalposition, condposition + 4);
            }
            else if (expression.IsBinaryMessage)
                this.block.CompileBinarySend(expression.Selector);
            else
                this.block.CompileSend(expression.Selector);
        }

Same methods

BytecodeCompiler::Visit ( ArrayExpression expression ) : void
BytecodeCompiler::Visit ( BlockExpression expression ) : void
BytecodeCompiler::Visit ( ClassModel @class ) : void
BytecodeCompiler::Visit ( ClassVariableExpression expression ) : void
BytecodeCompiler::Visit ( CodeModel model ) : void
BytecodeCompiler::Visit ( ConstantExpression expression ) : void
BytecodeCompiler::Visit ( DynamicArrayExpression expression ) : void
BytecodeCompiler::Visit ( FluentMessageExpression expression ) : void
BytecodeCompiler::Visit ( FreeBlockExpression block ) : void
BytecodeCompiler::Visit ( IEnumerable expressions ) : void
BytecodeCompiler::Visit ( InstanceVariableExpression expression ) : void
BytecodeCompiler::Visit ( MethodModel method ) : void
BytecodeCompiler::Visit ( PrimitiveExpression expression ) : void
BytecodeCompiler::Visit ( ReturnExpression expression ) : void
BytecodeCompiler::Visit ( SelfExpression expression ) : void
BytecodeCompiler::Visit ( SetExpression expression ) : void
BytecodeCompiler::Visit ( SymbolExpression expression ) : void
BytecodeCompiler::Visit ( VariableExpression expression ) : void

Usage Example

Пример #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);
        }