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


C# IokeObject.GetMimics方法代码示例

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


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

示例1: Init

        public static void Init(IokeObject obj)
        {
            obj.Kind = "Locals";
            obj.GetMimics().Clear();

            obj.SetCell("=",         obj.runtime.Base.Cells["="]);
            var assgn = IokeObject.As(obj.runtime.DefaultBehavior.Cells["Assignment"], null).Cells;
            obj.SetCell("++",        assgn["++"]);
            obj.SetCell("--",        assgn["--"]);
            obj.SetCell("+=",        assgn["+="]);
            obj.SetCell("-=",        assgn["-="]);
            obj.SetCell("/=",        assgn["/="]);
            obj.SetCell("*=",        assgn["*="]);
            obj.SetCell("%=",        assgn["%="]);
            obj.SetCell("**=",       assgn["**="]);
            obj.SetCell("&=",        assgn["&="]);
            obj.SetCell("|=",        assgn["|="]);
            obj.SetCell("^=",        assgn["^="]);
            obj.SetCell("<<=",       assgn["<<="]);
            obj.SetCell(">>=",       assgn[">>="]);
            obj.SetCell("&&=",       assgn["&&="]);
            obj.SetCell("||=",       assgn["||="]);
            obj.SetCell("cell",         obj.runtime.Base.Cells["cell"]);
            obj.SetCell("cell=",         obj.runtime.Base.Cells["cell="]);
            obj.SetCell("cells",         obj.runtime.Base.Cells["cells"]);
            obj.SetCell("cellNames",         obj.runtime.Base.Cells["cellNames"]);
            obj.SetCell("removeCell!",         obj.runtime.Base.Cells["removeCell!"]);
            obj.SetCell("undefineCell!",         obj.runtime.Base.Cells["undefineCell!"]);
            obj.SetCell("cellOwner?",         obj.runtime.Base.Cells["cellOwner?"]);
            obj.SetCell("cellOwner",         obj.runtime.Base.Cells["cellOwner"]);
            obj.SetCell("identity",         obj.runtime.Base.Cells["identity"]);

            obj.RegisterMethod(obj.runtime.NewNativeMethod("will pass along the call to the real self object of this context.",
                                                           new NativeMethod("pass", DefaultArgumentsDefinition.builder()
                                                                            .WithRestUnevaluated("arguments")
                                                                            .Arguments,
                                                                            (method, context, message, on, outer) => {
                                                                                object selfDelegate = IokeObject.As(on, context).Self;
                                                                                if(selfDelegate != null && selfDelegate != on) {
                                                                                    return IokeObject.Perform(selfDelegate, context, message);
                                                                                }
                                                                                return context.runtime.nil;
                                                                            })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("will return a text representation of the current stack trace",
                                                           new NativeMethod.WithNoArguments("stackTraceAsText",
                                                                                            (method, context, m, on, outer) => {
                                                                                                outer.ArgumentsDefinition.CheckArgumentCount(context, m, on);
                                                                                                Runtime runtime = context.runtime;
                                                                                                StringBuilder sb = new StringBuilder();

                                                                                                IokeObject current = IokeObject.As(on, context);
                                                                                                while("Locals".Equals(current.GetKind(m, context))) {
                                                                                                    IokeObject message = IokeObject.As(IokeObject.GetCell(current, m, context, "currentMessage"), context);
                                                                                                    IokeObject start = message;

                                                                                                    while(Message.GetPrev(start) != null && Message.GetPrev(start).Line == message.Line) {
                                                                                                        start = Message.GetPrev(start);
                                                                                                    }

                                                                                                    string s1 = Message.Code(start);

                                                                                                    int ix = s1.IndexOf("\n");
                                                                                                    if(ix > -1) {
                                                                                                        ix--;
                                                                                                    }

                                                                                                    sb.Append(string.Format(" {0,-48} {1}\n",
                                                                                                                            (ix == -1 ? s1 : s1.Substring(0,ix)),
                                                                                                                            "[" + message.File + ":" + message.Line + ":" + message.Position + GetContextMessageName(IokeObject.As(current.Cells["surroundingContext"], context)) + "]"));

                                                                                                    current = IokeObject.As(IokeObject.FindCell(current, m, context, "surroundingContext"), context);
                                                                                                }

                                                                                                return runtime.NewText(sb.ToString());
                                                                                            })));
        }
开发者ID:vic,项目名称:ioke-outdated,代码行数:77,代码来源:Locals.cs


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