Example #1
0
            public void AddInstructions(LightCompiler compiler)
            {
                var endOfTrue  = compiler.Instructions.MakeLabel();
                var endOfFalse = compiler.Instructions.MakeLabel();

                // condition
                compiler.Compile(_expr);
                compiler.CompileSetVariable(LightExceptionRewriter._lastValue, false);
                compiler.Instructions.Emit(IsLightExceptionInstruction.Instance);

                // true - an exception occured
                compiler.Instructions.EmitBranchFalse(endOfTrue);

                if (_lastValue != null)
                {
                    compiler.CompileParameterExpression(_lastValue);
                }

                compiler.Instructions.EmitGoto(
                    compiler.GetBranchLabel(_target),
                    _retType != typeof(void),
                    _lastValue != null && _lastValue.Type != typeof(void)
                    );
                compiler.Instructions.EmitBranch(endOfFalse, false, true);

                // false - no exception
                compiler.Instructions.MarkLabel(endOfTrue);
                compiler.CompileParameterExpression(LightExceptionRewriter._lastValue);
                compiler.Instructions.MarkLabel(endOfFalse);
            }