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


C# CodeGenContext.ldarg方法代码示例

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


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

示例1: Assign

        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // thisblock.localsN.SetDynamic("vid", value);
            context.ldarg(0);
            context.ldfld(block.frameFields[depth - 1]);
            context.ldstr(Name);
            value.GenSimple(context);
            context.call(Runtime.Frame.SetDynamic);

            value.GenSimple(context);

            context.ReleaseLocal(value, created);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:17,代码来源:Variables.cs

示例2: GenSimple

 public virtual void GenSimple(CodeGenContext context)
 {        
     // thisblock.localsN.vid
     context.ldarg(0);
     context.ldfld(block.frameFields[depth - 1]);
     context.ldfld(field);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:7,代码来源:Variables.cs

示例3: 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

示例4: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            CodeGenContext Begin = context.CreateMethod(FileClass(), MethAttr.PublicStatic, "Begin" + (seq++), PrimitiveType.Object,
                    new Param(ParamAttr.Default, "recv", PrimitiveType.Object),
                    new Param(ParamAttr.Default, "caller", Runtime.FrameRef));

            Begin.startMethod(this.location);

            AddScopeLocals(Begin);

            AddScopeBody(Begin);

            Begin.ReleaseLocal(0, true);

            Begin.Close();


            // Begin(recv, caller);
            context.ldarg("recv");
            context.ldloc(0);
            context.call(Begin.Method);
            context.pop();
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:23,代码来源:Methods.cs

示例5: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            context.newLine(location);

            if (return_val != null)
                return_val.GenCode(context);
            else
                context.ldnull();

            if (this.parent_scope is BLOCK)
            {
                //throw new Ruby.ReturnException(return_value, this.defining_scope);
                context.ldarg(0);  // current Ruby.MethodBody
                context.ldfld(Runtime.Block.defining_scope);
                context.newobj(Runtime.ReturnException.ctor);
                context.throwOp();
            }
            else if (this.parent_scope is BEGIN)
            {
                //throw new Ruby.ReturnException(return_value, caller);
                context.ldarg("caller");
                context.newobj(Runtime.ReturnException.ctor);
                context.throwOp();
            }
            else
            {
                // return
                context.stloc(parent_scope.returnTemp);
                context.Goto(context.labels.Return);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:31,代码来源:ControlFlow.cs

示例6: CopySimple

        internal void CopySimple(CodeGenContext context, Scope scope)
        {
            if (block != null)
            {
                // locals.block = block;
                string bname = ID.ToDotNetName(block.vid);
                context.ldloc(0);
                LoadBlock(context);
                context.stfld(scope.GetFrameField(bname));
            }

            for (Node f = normal; f != null; f = f.nd_next)
            {
                string fname = ID.ToDotNetName(((VAR)f).vid);

                // local.f = f;
                context.ldloc(0);
                context.ldarg(fname);
                context.stfld(scope.GetFrameField(fname));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:21,代码来源:Formals.cs

示例7: CopyRestFormals

        private void CopyRestFormals(CodeGenContext context, Scope scope)
        {
            if (rest != null)
            {
                string name = ID.ToDotNetName(rest.vid);

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

示例8: CopyOptionalFormals

        private void CopyOptionalFormals(CodeGenContext context, Scope scope)
        {
            for (ASSIGNMENT opt = (ASSIGNMENT)optional; opt != null; opt = (ASSIGNMENT)opt.nd_next)
            {
                PERWAPI.CILLabel runout_label = context.NewLabel();
                PERWAPI.CILLabel end_label = context.NewLabel();

                string name = ID.ToDotNetName(((VAR)(opt.lhs)).vid);
                Node defaultValue = opt.rhs;

  

                // if (args.RunOut()) goto RunOut
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.RunOut);
                context.brtrue(runout_label);

                // locals.name = args.GetNext();
                context.ldloc(0);
                context.ldarg("args");
                context.callvirt(Runtime.ArgList.GetNext);
                context.br(end_label);

                // RunOut:
                context.CodeLabel(runout_label);

                // object def = defaultValue;
                bool created;
                ISimple def = context.PreCompute(defaultValue, "default", out created);

                // locals.name = defaultValue
                context.ldloc(0);
                def.GenSimple(context);

                context.ReleaseLocal(def, created);

                context.CodeLabel(end_label);

                // locals.name = ...
                context.stfld(scope.GetFrameField(name));
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:42,代码来源:Formals.cs

示例9: LoadBlock0

 internal void LoadBlock0(CodeGenContext context)
 {
     if (context.HasArg(Runtime.ArgListRef))
     {
         context.ldarg("args"); // args.block
         context.ldfld(Runtime.ArgList.block);
     }
     else if (context.HasArg(Runtime.ProcRef))
     {
         context.ldarg("block");
     }
     else
         context.ldnull();
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:14,代码来源:Node.cs

示例10: Defined

   internal override void Defined(CodeGenContext context)
 {
     // Eval.ivar_defined(recv, vid)
     context.ldarg("recv");
     context.ldstr(vid);
     context.call(Runtime.Eval.ivar_defined);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:7,代码来源:Variables.cs

示例11: DefineClass

 internal override void DefineClass(CodeGenContext context, PERWAPI.FieldDef singleton)
 {
     // Class.singleton_class(caller, super)
     context.ldloc(0);
     context.ldarg("super");
     context.call(Runtime.Class.singleton_class);
     context.stsfld(singleton);
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:8,代码来源:ClassesAndModules.cs

示例12: GenCode0


//.........这里部分代码省略.........
            if (context.currentSkeleton.nestedClasses.ContainsKey(basename))
                skeleton = context.currentSkeleton.nestedClasses[basename];
            else
                skeleton = new ClassSkeleton(basename, classRef);
            skeleton.lexicalParent = context.currentSkeleton;
            newContext.currentSkeleton = skeleton;
            skeleton.lexicalParent.nestedClasses[basename] = skeleton;

            if (!superClassFound && this is AST.CLASS && ((AST.CLASS)this).super_class != null && defineInteropClass)
            {
                // do not add to post pass list if supertype is a built-in Ruby class
                //List<string> qualifiedSuperClass = ClassSkeleton.ConstNodeToClassList(((AST.CLASS)this).super_class);
                //if (!(qualifiedSuperClass.Count == 1 && Ruby.Runtime.BuiltinClasses.IsBuiltinClass(qualifiedSuperClass[0])))
                newContext.postPassList.Add(new ClassSkeletonPostPass(skeleton, interopClass, ((AST.CLASS)this).super_class));
            }
          
            //    public static Class classname;
            int seqNo = 0;
            internal_name = basename;
            while (FileClass().GetField(internal_name) != null)
                internal_name = basename + (seqNo++);

            // Define singleton in file class so that it gets initialized by .cctor
            singletonField = FileClass().AddField(PERWAPI.FieldAttr.PublicStatic, internal_name, Runtime.ClassRef);
            newContext.CurrentRubyClass = singletonField;

            //    public MyClass() : base(singleton) { };
            CodeGenContext class_constructor = null; 
            if (defineInteropClass)
            {
                if (interopClass.GetMethod(".ctor", new Type[0]) == null)
                {
                    CodeGenContext class_constructor0 = newContext.CreateConstructor(interopClass);
                    class_constructor0.ldarg(0);
                    if (superClassConstructor0 != null)
                        class_constructor0.call(superClassConstructor0);
                    else
                    {
                        class_constructor0.ldsfld(singletonField);
                        class_constructor0.call(superClassConstructor1);
                    }
                    class_constructor0.ret();
                    class_constructor0.Close();
                }


                //    public MyClass(Class klass) : base(klass) { };
                MethodDef ctor = interopClass.GetMethod(".ctor", new Type[] { Runtime.ClassRef });
                //CodeGenContext class_constructor;
                if (ctor == null)
                {
                    class_constructor = newContext.CreateConstructor(interopClass, new Param(ParamAttr.Default, "klass", Runtime.ClassRef));
                    class_constructor.ldarg(0);
                    class_constructor.ldarg("klass");
                    class_constructor.call(superClassConstructor1);
                    class_constructor.ret();
                    class_constructor.Close();
                }
                else
                {
                    class_constructor = new CodeGenContext();
                    class_constructor.Method = ctor;
                }
            }

            //    internal static void Init_fullname(object scope, object super, object recv, Frame caller) {
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:67,代码来源:ClassesAndModules.cs

示例13: AddScopeLocals

        internal void AddScopeLocals(CodeGenContext context)
        {
            // ------------------ Start new Context ----------------------------

            // [InteropMethod("MyClass")]
            // private class ActivationFrame: Ruby.Frame { ... }
            frame_def = context.CreateGlobalClass("_Internal", "Frame" + (N++), Runtime.FrameRef);

            Scope parentClass;
            for (parentClass = this; parentClass != null && !(parentClass is CLASS_OR_MODULE); parentClass = parentClass.parent_scope) ;

            string className = "";
            if (parentClass != null)
                className = ((CLASS_OR_MODULE)parentClass).internal_name;

            ClassDef fileClass = FileClass();
            string src = "";
            if (fileClass != null && fileClass.Name().StartsWith("SourceFile_"))
            {
                src = fileClass.Name().Substring(11);
                frame_def.AddCustomAttribute(Runtime.FrameAttribute.ctor, new Constant[] { new StringConst(src), new StringConst(className) });
            }

            foreach (string local in locals_list)
                CodeGenContext.AddField(frame_def, PERWAPI.FieldAttr.Public, ID.ToDotNetName(local), PrimitiveType.Object);

            // internal ActivationFrame(Frame caller): base(caller) { }
            CodeGenContext frame_ctor = context.CreateConstructor(frame_def, new Param(ParamAttr.Default, "caller", Runtime.FrameRef));
            frame_ctor.ldarg(0);
            frame_ctor.ldarg("caller");
            frame_ctor.call(Runtime.Frame.ctor);
            frame_ctor.ret();
            frame_ctor.Close();

            // internal string file() {
            CodeGenContext file = context.CreateMethod(frame_def, PERWAPI.MethAttr.PublicVirtual, "file", PrimitiveType.String);

            file.startMethod(this.location);
            //    return "thisfile.rb"
            file.ldstr(this.location.file);
            file.ret();
            file.Close();

            // internal override string methodName() {
            CodeGenContext methodName = context.CreateMethod(frame_def, PERWAPI.MethAttr.PublicVirtual, "methodName", PrimitiveType.String);
            methodName.startMethod(this.location);
            //    return "CurrentMethodName"
            methodName.ldstr(CurrentMethodName());
            methodName.ret();
            methodName.Close();

            CreateNestingMethod(frame_def, context);
            CreateLastClassMethod(frame_def, context);

            // ------------------ Return to Old Context ----------------------

            // ActivationFrame frame = new ActivationFrame(caller);
            context.ldarg("caller");
            context.newobj(frame_ctor.Method);
            int frame = context.StoreInTemp("frame", FrameClass, location);
            Debug.Assert(frame == 0);

            // frame.block_arg = block;
            context.ldloc(frame);
            LoadBlock0(context);
            context.stfld(Runtime.Frame.block_arg);

            if (this is BLOCK)
            {
                // frame.current_block = this;
                context.ldloc(frame);
                context.ldarg(0);
                context.stfld(Runtime.Frame.current_block);
            }
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:75,代码来源:Scoping.cs

示例14: GenSimple

 public void GenSimple(CodeGenContext context)
 {
     context.ldarg("recv");
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:4,代码来源:Singletons.cs


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