Esempio n. 1
0
 public void EmitCheckDone(IBlockContext context, LabelRef loop)
 {
     currentIndex.EmitLoad(context);
     context.IL.Emit(OpCodes.Ldc_I4_1);
     context.IL.Emit(OpCodes.Conv_I8);
     context.IL.Emit(OpCodes.Add);
     context.IL.Emit(OpCodes.Dup);
     currentIndex.EmitStore(context);
     rangeRef.EmitLoad(context);
     context.IL.Emit(OpCodes.Ldfld, typeof(Range).GetField("to"));
     context.IL.Emit(loop.isShort ? OpCodes.Blt_S : OpCodes.Blt, loop);
 }
Esempio n. 2
0
 public void EmitInitialize(IBlockContext context)
 {
     rangeRef = context.DeclareHiddenLocal(typeof(Range));
     rangeRef.EmitStore(context);
     currentIndex = context.DeclareHiddenLocal(typeof(long));
     rangeRef.EmitLoad(context);
     context.IL.Emit(OpCodes.Ldfld, typeof(Range).GetField("from"));
     context.IL.Emit(OpCodes.Ldc_I4_1);
     context.IL.Emit(OpCodes.Conv_I8);
     context.IL.Emit(OpCodes.Sub);
     currentIndex.EmitStore(context);
 }
 internal void EmitPoll(AsyncBlockContext context)
 {
     context.IL.MarkLabel(pollLabel);
     context.IL.Emit(OpCodes.Ldarg_0);
     context.IL.Emit(OpCodes.Ldfld, futureField);
     context.IL.EmitCall(OpCodes.Callvirt, futureField.FieldType.GetMethod("PollValue"), 1);
     futureResultVar.EmitStore(context);
     futureResultVar.EmitLoad(context);
     context.IL.Emit(OpCodes.Ldfld, futureResultVar.LocalType.GetField("ready"));
     context.IL.Emit(OpCodes.Brfalse, context.notReady);
     context.IL.Emit(OpCodes.Br, context.resume);
 }
Esempio n. 4
0
        public override void EmitCode(IBlockContext context, bool dropResult)
        {
            if (preparedResult != null)
            {
                if (!dropResult)
                {
                    preparedResult.EmitLoad(context);
                }
                preparedResult = null;
                return;
            }

            TO2Type targetType          = target.ResultType(context);
            IMethodInvokeFactory method = targetType.FindMethod(context.ModuleContext, methodName);

            if (method != null)
            {
                EmitCodeMethodCall(context, targetType, method, dropResult);
                return;
            }

            IFieldAccessFactory field = targetType.FindField(context.ModuleContext, methodName);

            if (field != null)
            {
                EmitCodeDelegateCall(context, targetType, field, dropResult);
                return;
            }

            context.AddError(new StructuralError(
                                 StructuralError.ErrorType.NoSuchMethod,
                                 $"Type '{targetType.Name}' does not have a method or field '{methodName}'",
                                 Start,
                                 End
                                 ));
        }
Esempio n. 5
0
 public void EmitLoad(IBlockContext context) => localRef.EmitLoad(context);
 internal void EmitStore(AsyncBlockContext context)
 {
     context.IL.Emit(OpCodes.Ldarg_0);
     localRef.EmitLoad(context);
     context.IL.Emit(OpCodes.Stfld, storageField);
 }