예제 #1
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_left);
     ctx.Compile(_right);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit(OpCodes.Ceq);
 }
예제 #2
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var forceNonVirtualCall = _forceNonVirtualCall;

            if (_instance != null)
            {
                ctx.Compile(_instance);
                if (_instance.ExpressionType.IsValueType)
                {
                    forceNonVirtualCall = true;
                }
            }

            foreach (var argument in _arguments)
            {
                ctx.Compile(argument);
            }

            ctx.MarkSequencePointFor(expressionId);

            if (!forceNonVirtualCall && _methodInfo.IsVirtual && !_methodInfo.IsFinal)
            {
                ctx.Generator.Emit(OpCodes.Callvirt, _methodInfo.GetBaseDefinition());
            }
            else
            {
                ctx.Generator.Emit(OpCodes.Call, _methodInfo);
            }
        }
예제 #3
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_left);
     ctx.Compile(_right);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit(GetOpCode(CollectionHelper.Contains(_unsigned, _left.ExpressionType)));
 }
예제 #4
0
        internal void Compile(IBuildContext ctx)
        {
            ctx.Generator.BeginCatchBlock(ExceptionType);
            var scope = ctx.EnterScope <CatchScope>();

            ctx.Compile(_preCatchExpression);
            ctx.Compile(_catchExpression);
            ctx.LeaveScope(scope);
        }
예제 #5
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            ctx.Compile(_predicate);
            var label = ctx.DefineLabel();

            label.EmitGoto(OpCodes.Brfalse); //TODO: use Brfalse_s if possible
            ctx.Compile(_thenExpression);
            label.Mark();
        }
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     if (_instance != null)
     {
         ctx.Compile(_instance);
     }
     ctx.Compile(_value);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit((_instance != null) ? OpCodes.Stfld : OpCodes.Stsfld, _fieldInfo);
 }
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            ctx.Compile(_arrayInstance);

            ctx.Compile(_index);
            EmitHelper.ConvertToNativeInt(ctx, _index.ExpressionType);

            ctx.MarkSequencePointFor(expressionId);

            EmitArrayAccess(ctx);
        }
예제 #8
0
        private void CompileTryBlock(IBuildContext ctx)
        {
            var scope = ctx.EnterScope <TryScope>();

            ctx.Compile(_tryExpression);
            ctx.LeaveScope(scope);
        }
예제 #9
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_arrayInstance);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit(OpCodes.Ldlen);//native int
     ctx.Generator.Emit(OpCodes.Conv_I4);
 }
예제 #10
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_count);
     EmitHelper.ConvertToNativeInt(ctx, _count.ExpressionType);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit(OpCodes.Newarr, _elementType);
 }
예제 #11
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var trueLabel = ctx.DefineLabel();
            var endLabel  = ctx.DefineLabel();

            ctx.Compile(_predicate);
            trueLabel.EmitGoto(OpCodes.Brtrue); //TODO: use Brtrue_s if possible

            ctx.Compile(_elseExpression);
            endLabel.EmitGoto(OpCodes.Br); //TODO: use Br_s if possible

            trueLabel.Mark();
            ctx.Compile(_thenExpression);

            endLabel.Mark();
        }
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            ctx.Compile(_expression);
            var local = ctx.Generator.DeclareLocal(_expression.ExpressionType);

            ctx.Generator.Emit(OpCodes.Stloc, local);
            ctx.Generator.Emit(OpCodes.Ldloca, local);
        }
예제 #13
0
        private void CompileFinallyBlock(IBuildContext ctx)
        {
            ctx.Generator.BeginFinallyBlock();

            var scope = ctx.EnterScope <FinallyScope>();

            ctx.Compile(_finallyExpression);
            ctx.LeaveScope(scope);
        }
예제 #14
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            ctx.Compile(_left);
            ctx.Compile(_right);
            ctx.MarkSequencePointFor(expressionId);

            if (!_overflowCheck || CollectionHelper.Contains(_overflowIgnorant, _left.ExpressionType))
            {
                ctx.Generator.Emit(OpCodes.Add);
            }
            else if (CollectionHelper.Contains(_overflowUnsigned, _left.ExpressionType) && CollectionHelper.Contains(_overflowUnsigned, _right.ExpressionType))
            {
                ctx.Generator.Emit(OpCodes.Add_Ovf_Un);
            }
            else
            {
                ctx.Generator.Emit(OpCodes.Add_Ovf);
            }
        }
예제 #15
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var scope = ctx.EnterScope <VoidBlockScope>();

            foreach (var expression in _expressions)
            {
                ctx.Compile(expression);
            }
            ctx.LeaveScope(scope);
        }
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var local = ctx.DeclareLocal(_variable);

            if (_initialValue != null)
            {
                ctx.Compile(_initialValue);

                ctx.MarkSequencePointFor(expressionId);
                LocalWriteExpression.EmitWriteLocal(ctx, local);
            }
        }
예제 #17
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            ValidateReturnType(ctx);
            ValidateScope(ctx);

            if (_value != null)
            {
                ctx.Compile(_value);
            }

            ctx.MarkSequencePointFor(expressionId);
            ctx.Generator.Emit(OpCodes.Ret);
        }
예제 #18
0
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            var data = new LoopData(ctx.DefineLabel(), ctx.DefineLabel());

            ctx.SetLoopData(data);

            data.ContinueLabel.Mark();
            ctx.Compile(_loop);
            data.ContinueLabel.EmitGoto(OpCodes.Br);

            data.BreakLabel.Mark();
            ctx.ResetLoopData(data);
        }
예제 #19
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     foreach (var argument in _arguments)
     {
         ctx.Compile(argument);
     }
     ctx.MarkSequencePointFor(expressionId);
     if (_constructorInfo == null)
     {
         EmitStructInit(ctx);
     }
     else
     {
         ctx.Generator.Emit(OpCodes.Newobj, _constructorInfo);
     }
 }
        internal override void Compile(IBuildContext ctx, int expressionId)
        {
            if (_instance != null)
            {
                ctx.Compile(_instance);
            }

            ctx.MarkSequencePointFor(expressionId);

            if (_loadAddress)
            {
                ctx.Generator.Emit((_instance != null) ? OpCodes.Ldflda : OpCodes.Ldsflda, _fieldInfo);
            }
            else
            {
                ctx.Generator.Emit((_instance != null) ? OpCodes.Ldfld : OpCodes.Ldsfld, _fieldInfo);
            }
        }
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_value);
     ctx.MarkSequencePointFor(expressionId);
     EmitWriteLocal(ctx, ctx.GetLocal(_variable));
 }
예제 #22
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(Expression);
     ctx.MarkSequencePointFor(expressionId);
     _conversionMethod(ctx);
 }
예제 #23
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_expression);
     ctx.Generator.Emit(OpCodes.Pop);
 }
예제 #24
0
 internal override void Compile(IBuildContext ctx, int expressionId)
 {
     ctx.Compile(_expression);
     ctx.MarkSequencePointFor(expressionId);
     ctx.Generator.Emit(OpCodes.Throw);
 }