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


C# CodeGenContext.PreCompute方法代码示例

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


在下文中一共展示了CodeGenContext.PreCompute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            bool created;
            ISimple left = context.PreCompute(lhs, "lhs", out created);

            new COND((Node)left, rhs, (Node)left, location).GenCode(context);

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

示例3: PushScope

 private ISimple PushScope(CodeGenContext context, out bool created)
 {
     if (name != null && name.scope != null)
         return context.PreCompute(name.scope, "scope", out created);
     else
     {
         created = false;
         if (context.CurrentRubyClass != null)
             return new StaticField(context.CurrentRubyClass, name.location);
         else
             return new StaticField(Runtime.Init.rb_cObject, name.location);
     }
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:13,代码来源:ClassesAndModules.cs

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

示例5: PushSuper

 protected override ISimple PushSuper(CodeGenContext context, out bool created)
 {
     return context.PreCompute(singleton, "super", out created); // pass singleton as super
 }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:4,代码来源:ClassesAndModules.cs

示例6: GenArgList

        internal override ISimple GenArgList(CodeGenContext context, out bool created)
        {
            bool single = true;

            // ArgList arglist = new ArgList();
            context.newobj(Runtime.ArgList.ctor);
            int arglist = context.StoreInTemp("arglist", Runtime.ArgListRef, location);

            int added = 0;
            for (Node arg = parameters; arg != null; arg = arg.nd_next)
            {
                //object argument = arg;
                bool argument_created;
                ISimple argument = context.PreCompute0(arg, "arg", out argument_created);

                // arglist.Add(argument);
                context.ldloc(arglist);
                argument.GenSimple(context);
                context.callvirt(Runtime.ArgList.Add);
                added++;

                context.ReleaseLocal(argument, argument_created);
            }

            if (added != 1)
                single = false;

            if (hashlist != null)
            {
                // object hash = hashlist;
                bool hash_created;
                ISimple hash = context.PreCompute(new HASH(hashlist, hashlist.location), "hashlist", out hash_created);

                // arglist.Add(hash);
                context.ldloc(arglist);
                hash.GenSimple(context);
                context.callvirt(Runtime.ArgList.Add);
                single = false;

                context.ReleaseLocal(hash, hash_created);
            }

            if (array != null)
            {
                // object list = array;
                bool list_created;
                ISimple list = context.PreCompute(array, "array", out list_created);

                // arglist.AddArray(list, caller);
                context.ldloc(arglist);
                list.GenSimple(context);
                context.ldloc(0);
                context.callvirt(Runtime.ArgList.AddArray);
                single = false;

                context.ReleaseLocal(list, list_created);
            }

            if (block != null)
            {
                // object b = block;
                bool b_created;
                ISimple b = context.PreCompute(block, "block", Runtime.ProcRef, out b_created);

                // arglist.block = b;
                context.ldloc(arglist);
                b.GenSimple(context);
                context.stfld(Runtime.ArgList.block);

                context.ReleaseLocal(b, b_created);
            }

            if (single)
            {
                context.ldloc(arglist);
                context.PushTrue();
                context.stfld(Runtime.ArgList.single_arg);
            }

            created = true;
            return new LOCAL(arglist, location);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:82,代码来源:Args.cs

示例7: GenFixedArgs

        internal override List<ISimple> GenFixedArgs(CodeGenContext context, out List<bool> created)
        {
            List<ISimple> fixed_args = new List<ISimple>();
            created = new List<bool>();

            if (block != null)
            {
                bool b_created;
                fixed_args.Add(context.PreCompute(block, "block", Runtime.ProcRef, out b_created));
                created.Add(b_created);
            }
            else
            {
                fixed_args.Add(new AST.NIL(location));
                created.Add(false);
            }

            for (Node arg = parameters; arg != null; arg = arg.nd_next)
            {
                //object argument = arg;
                bool argument_created;
                fixed_args.Add(context.PreCompute0(arg, "arg", out argument_created));
                created.Add(argument_created);
            }

            return fixed_args;
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:27,代码来源:Args.cs

示例8: AssignOp

        internal void AssignOp(CodeGenContext context, string op, Node rhs)
        {
            // object a = array;
            bool a_created;
            ISimple a = context.PreCompute(array, "array", out a_created);

            // ArgList index = args;
            bool index_created;
            index = args.GenArgList(context, out index_created);

            // access <=> a[index];
            ARRAY_ACCESS access = new ARRAY_ACCESS((Node)a, new ProxyList(Index, location), location);

            // access1 = (access2 op rhs);
            access.Assign(context, METHOD_CALL.Create(access, op, rhs, location));

            context.ReleaseLocal(a, a_created);
            context.ReleaseLocal(index, index_created);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:19,代码来源:Variables.cs

示例9: ArgsPlusRHS

        // append rhs to args array
        private ISimple ArgsPlusRHS(CodeGenContext context, out bool created)
        {
            // ArgList temp = args;
            ISimple temp = args.GenArgList(context, out created);

            // object value = rhs;
            bool value_created;
            ISimple value = context.PreCompute(rhs, "rhs", out value_created);

            // temp.Add(value);
            temp.GenSimple(context);
            value.GenSimple(context);
            context.callvirt(Runtime.ArgList.Add);

            context.ReleaseLocal(value, value_created);

            return temp;
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:19,代码来源:Variables.cs

示例10: GenCode0

        internal override void GenCode0(CodeGenContext context)
        {
            if (Scanner.is_identchar(method_id[0]))
                context.newLine(location);
            
            SetLine(context);
            
            bool self_created, arguments_created = false;

            if (isVarAccess)
            {
                context.ldloc(0);
                context.call(Runtime.Frame.SetCallStatusVCall);
            }
            else
            {
                context.ldloc(0);
                context.call(Runtime.Frame.SetCallStatusNone);
            }

            // object self = receiver;
            self = context.PreCompute(receiver, "receiver", out self_created);

            if (args.ShortAndSimple())
                fixed_arguments = args.GenFixedArgs(context, out fixed_created);
            else
                arguments = args.GenArgList(context, out arguments_created);


            GenCall(context);

            context.ReleaseLocal(self, self_created);

            if (args.ShortAndSimple())
                for (int i = 0; i < fixed_created.Count; i++)
                    context.ReleaseLocal(fixed_arguments[i], fixed_created[i]);
            else
                context.ReleaseLocal(arguments, arguments_created);
        }
开发者ID:chunlea,项目名称:rubydotnetcompiler,代码行数:39,代码来源:Calls.cs


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