当前位置: 首页>>代码示例>>C#>>正文


C# CodeGenContext.box方法代码示例

本文整理汇总了C#中CodeGenContext.box方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.box方法的具体用法?C# CodeGenContext.box怎么用?C# CodeGenContext.box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGenContext的用法示例。


在下文中一共展示了CodeGenContext.box方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenSimple

        public void GenSimple(CodeGenContext context)
        {
            if (value is string)// T_STRING,
            {
                context.ldstr((string)(value));
                context.newobj(Runtime.String.ctor);
                return;
            }
            if (value is int)   // T_FIXNUM
            {
                context.ldc_i4((int)(value));
                context.box(PrimitiveType.Int32);
                return;
            }
            if (value is double)// T_FLOAT
            {
                context.ldc_r8((double)(value));
                context.newobj(Runtime.Float.ctor);
                return;
            }
            if (value is ID)    // T_SYMBOL
            {
                context.ldstr(((ID)value).ToString());
                context.newobj(Runtime.Symbol.ctor);
                return;
            }
            if (value is BigNum)
            {
                BigNum num = (BigNum) value;
                context.ldc_i4(num.sign);
                context.ldstr(num.ToString());
                context.ldc_i4(num.bas);
                context.newobj(Runtime.Bignum.ctor);
                return;
            }

            throw new System.NotImplementedException("VALUE " + value.GetType().ToString());
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:38,代码来源:VALUE.cs

示例2: Defined

   internal override void Defined(CodeGenContext context)
 {
     context.PushTrue();
     context.box(PrimitiveType.Boolean);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:5,代码来源:Variables.cs

示例3: Defined

          internal override void Defined(CodeGenContext context)
        {
            PERWAPI.CILLabel undefined_label = context.NewLabel();
            PERWAPI.CILLabel end_label = context.NewLabel();

            for (Node arg = parameters; arg != null; arg = arg.nd_next)
            {
                arg.Defined(context);
                context.brfalse(undefined_label);
            }

            if (array != null)
            {
                array.Defined(context);
                context.brfalse(undefined_label);
            }

            if (hashlist != null)
            {
                hashlist.Defined(context);
                context.brfalse(undefined_label);
            }

            if (block != null)
            {
                block.Defined(context);
                context.brfalse(undefined_label);
            }

            context.PushTrue();
            context.box(PrimitiveType.Boolean);

            if (!IsEmpty)
            {
                context.br(end_label);

                context.CodeLabel(undefined_label);
                context.PushFalse();
                context.box(PrimitiveType.Boolean);

                context.CodeLabel(end_label);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:43,代码来源:Args.cs

示例4: CopyNormalFormals

        private void CopyNormalFormals(CodeGenContext context, Scope scope)
        {
            PERWAPI.CILLabel OKLabel = context.NewLabel();

            if (min_args > 0)
            {
                // if (args.Length < min_args)
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.get_Length);
                int length = context.StoreInTemp("length", PrimitiveType.Int32, location);
                context.ldloc(length);
                context.ldc_i4(min_args);
                context.bge(OKLabel);

                //context.Inst(Op.clt);
                //context.brfalse(OKLabel);

                // context.Branch(BranchOp.bge, OKLabel);

                // throw new ArgumentError(string.Format("wrong number of arguments ({0} for {1})", args.Length, arity).raise(caller);
                // FIXME: next line needs a String
                context.ldstr("wrong number of arguments ({0} for {1})");
                context.ldloc(length);
                context.box(PrimitiveType.Int32);
                context.ldc_i4(min_args);
                context.box(PrimitiveType.Int32);
                context.call(Runtime.SystemString.Format);
                context.newobj(Runtime.ArgumentError.ctor);
                context.ldloc(0);
                context.callvirt(Runtime.Exception.raise);
                context.throwOp();

                context.ReleaseLocal(length, true);

                // OKLabel:
                context.CodeLabel(OKLabel);
            }

            // Copy parameters to locals
            for (Node f = normal; f != null; f = f.nd_next)
            {
                string name = ID.ToDotNetName(((VAR)f).vid);

                // local.f = args.GetNext();
                context.ldloc(0);
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.GetNext);
                context.stfld(scope.GetFrameField(name));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:50,代码来源:Formals.cs

示例5: GenSimple

 public void GenSimple(CodeGenContext context)
 {
     context.PushTrue();
     context.box(PrimitiveType.Boolean);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:5,代码来源:Singletons.cs


注:本文中的CodeGenContext.box方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。