示例#1
0
        private CompilerFunction(Compiler compiler, FunctionDeclaration prototype)
            : base(compiler)
        {
            Contract.Requires(compiler != null);
            Contract.Requires(prototype != null);

            _functionPrototype = prototype;

            _entryLabel = compiler.DefineLabel();
            _exitLabel = compiler.DefineLabel();
            _entryTarget = compiler.GetTarget(_entryLabel.Id);
            _exitTarget = compiler.GetTarget(_exitLabel.Id);

            _end = new CompilerFunctionEnd(compiler, this);
        }
        public CompilerJmpInstruction(Compiler compiler, InstructionCode code, Operand[] operands)
            : base(compiler, code, operands)
        {
            if (code < InstructionDescription.JumpBegin || code > InstructionDescription.JumpEnd)
                throw new ArgumentException("The specified instruction code is not a valid jump.");
            Contract.Requires(compiler != null);
            Contract.Requires(operands != null);
            Contract.EndContractBlock();

            _jumpTarget = compiler.GetTarget(Operands[0].Id);
            _jumpTarget.JumpsCount++;

            _jumpNext = _jumpTarget.From;
            _jumpTarget.From = this;

            _isTaken =
                Code == InstructionCode.Jmp
                || (Operands.Length > 1 && Operands[1].IsImm && ((Imm)Operands[1]).Value == (IntPtr)Hint.Taken);
        }