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


C# IokeObject.SetCell方法代码示例

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


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

示例1: WalkWithoutExplicitReceiver

 private static void WalkWithoutExplicitReceiver(object onAsMessage, IokeObject c, string name, IokeObject code)
 {
     object o = onAsMessage;
     while(o != null) {
         c.SetCell(name, o);
         code.runtime.interpreter.Evaluate(code, c, c.RealContext, c);
         foreach(object arg in ((IokeObject)o).Arguments) {
             WalkWithoutExplicitReceiver(arg, c, name, code);
         }
         o = GetNext(o);
     }
 }
开发者ID:goking,项目名称:ioke,代码行数:12,代码来源:Message.cs

示例2: AfterInitRuntime

        public void AfterInitRuntime(IokeObject obj)
        {
            try {
                using(Stream str = typeof(IokeSystem).Assembly.GetManifestResourceStream("Ioke.Lang.version.properties")) {
                    using(StreamReader sr = new StreamReader(str, NETSystem.Text.Encoding.UTF8)) {
                        var result = new Dictionary<string, string>();
                        while(!sr.EndOfStream) {
                            string ss = sr.ReadLine();
                            if(ss.IndexOf('=') != -1) {
                                string[] parts = ss.Split('=');
                                result[parts[0].Trim()] = parts[1].Trim();
                            }
                        }

                        string version = result["ioke.build.version"];
                        string runtimeVersion = result["ioke.build.runtimeVersion"];
                        string versionString = result["ioke.build.versionString"];
                        string date = result["ioke.build.date"];
                        string commit = result["ioke.build.commit"];

                        IokeObject versionObj = NewFromOrigin();

                        versionObj.SetCell("machine", NewText("ikc"));

                        var versionParts = new SaneArrayList();
                        foreach(var s in runtimeVersion.Split(new Char[] {'.', '-'})) {
                            try {
                                versionParts.Add(NewNumber(s));
                            } catch(System.Exception) {
                                versionParts.Add(NewText(s));
                            }
                        }

                        versionObj.SetCell("versionNumber", NewList(versionParts));
                        versionObj.SetCell("release", NewText(version));
                        versionObj.SetCell("fullVersion", NewText(versionString));
                        versionObj.SetCell("commit", NewText(commit));
                        versionObj.SetCell("date", NewText(date));

                        obj.SetCell("version", versionObj);
                    }
                }
            } catch(System.Exception) {
            }
        }
开发者ID:goking,项目名称:ioke,代码行数:45,代码来源:Runtime.cs

示例3: AssignArgumentValues

        private void AssignArgumentValues(IokeObject locals, IokeObject context, IokeObject message, object on, IList argumentsWithoutKeywords, IDictionary<string, object> givenKeywords, int argCount)
        {
            Runtime runtime = context.runtime;

            var intersection = new SaneHashSet<string>(givenKeywords.Keys);
            foreach(string k in keywords) intersection.Remove(k);

            int ix = 0;
            for(int i=0, j=this.arguments.Count;i<j;i++) {
                Argument a = this.arguments[i];

                if(a is KeywordArgument) {
                    string nm = a.Name + ":";
                    object result = null;
                    if(givenKeywords.ContainsKey(nm)) {
                        object given = givenKeywords[nm];
                        result = given;
                        locals.SetCell(a.Name, result);
                    } else {
                        object defVal = ((KeywordArgument)a).DefaultValue;
                        if(!(defVal is string)) {
                            IokeObject m1 = IokeObject.As(defVal, context);
                            result = ((Message)IokeObject.dataOf(m1)).EvaluateCompleteWithoutExplicitReceiver(m1, locals, locals.RealContext);
                            locals.SetCell(a.Name, result);
                        }
                    }
                } else if((a is OptionalArgument) && ix>=argCount) {
                    object defVal = ((OptionalArgument)a).DefaultValue;
                    if(!(defVal is string)) {
                        IokeObject m2 = IokeObject.As(defVal, context);
                        locals.SetCell(a.Name, ((Message)IokeObject.dataOf(m2)).EvaluateCompleteWithoutExplicitReceiver(m2, locals, locals.RealContext));
                    }
                } else {
                    locals.SetCell(a.Name, argumentsWithoutKeywords[ix++]);
                }
            }

            if(krest != null) {
                var krests = new SaneHashtable();
                foreach(string s in intersection) {
                    object given = givenKeywords[s];
                    object result = given;
                    krests[runtime.GetSymbol(s.Substring(0, s.Length-1))] = result;
                }

                locals.SetCell(krest, runtime.NewDict(krests));
            }

            if(rest != null) {
                IList rests = new SaneArrayList();
                for(int j=argumentsWithoutKeywords.Count;ix<j;ix++) {
                    rests.Add(argumentsWithoutKeywords[ix]);
                }

                locals.SetCell(rest, runtime.NewList(rests));
            }
        }
开发者ID:vic,项目名称:ioke,代码行数:57,代码来源:DefaultArgumentsDefinition.cs

示例4: GetOpTable

 private static IDictionary GetOpTable(IokeParser parser, IokeObject opTable, string name, OpTableCreator creator)
 {
     IokeObject operators = IokeObject.As(opTable.FindCell(parser.message, parser.context, name), null);
     if(operators != parser.runtime.nul && (IokeObject.dataOf(operators) is Dict)) {
         return Dict.GetMap(operators);
     } else {
         IDictionary result = creator.Create(parser.runtime);
         opTable.SetCell(name, parser.runtime.NewDict(result));
         return result;
     }
 }
开发者ID:nope,项目名称:ioke,代码行数:11,代码来源:Operators.cs

示例5: Init

        public override void Init(IokeObject obj)
        {
            Runtime runtime = obj.runtime;

            obj.Kind = "Text";
            obj.Mimics(IokeObject.As(runtime.Mixins.GetCell(null, null, "Comparing"), null), runtime.nul, runtime.nul);
            obj.SetCell("==",        runtime.Base.Cells["=="]);

            obj.RegisterMethod(runtime.NewNativeMethod("Returns a text representation of the object",
                                                       new NativeMethod.WithNoArguments("asText",
                                                                                        (method, context, message, on, outer) => {
                                                                                            outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, new SaneArrayList(), new SaneDictionary<string, object>());
                                                                                            return on;
                                                                                        })));

            obj.RegisterMethod(runtime.NewNativeMethod("Takes any number of arguments, and expects the text receiver to contain format specifications. The currently supported specifications are only %s and %{, %}. These have several parameters that can be used. See the spec for more info about these. The format method will return a new text based on the content of the receiver, and the arguments given.",
                                                       new TypeCheckingNativeMethod("format", TypeCheckingArgumentsDefinition.builder()
                                                                                    .ReceiverMustMimic(obj)
                                                                                    .WithRest("replacements")
                                                                                    .Arguments,
                                                                                    (self, on, args, keywords, context, message) => {
                                                                                        StringBuilder result = new StringBuilder();
                                                                                        Format(on, message, context, args, result);
                                                                                        return context.runtime.NewText(result.ToString());
                                                                                    })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Converts the content of this text into a rational value",
                                                           new TypeCheckingNativeMethod.WithNoArguments("toRational", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return Text.ToRational(on, context, message);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Converts the content of this text into a decimal value",
                                                           new TypeCheckingNativeMethod.WithNoArguments("toDecimal", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return Text.ToDecimal(on, context, message);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("inspect", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return self.runtime.NewText(Text.GetInspect(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a brief text inspection of the object",
                                                           new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return self.runtime.NewText(Text.GetInspect(on));
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a lower case version of this text",
                                                           new TypeCheckingNativeMethod.WithNoArguments("lower", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return self.runtime.NewText(Text.GetText(on).ToLower());
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns an upper case version of this text",
                                                           new TypeCheckingNativeMethod.WithNoArguments("upper", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return self.runtime.NewText(Text.GetText(on).ToUpper());
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns a version of this text with leading and trailing whitespace removed",
                                                           new TypeCheckingNativeMethod.WithNoArguments("trim", obj,
                                                                                                        (self, on, args, keywords, context, message) => {
                                                                                                            return self.runtime.NewText(Text.GetText(on).Trim());
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Returns an array of texts split around the argument",
                                                           new TypeCheckingNativeMethod("split", TypeCheckingArgumentsDefinition.builder()
                                                                                        .ReceiverMustMimic(obj)
                                                                                        .WithOptionalPositional("splitAround", "")
                                                                                        .Arguments,
                                                                                        (self, on, args, keywords, context, message) => {
                                                                                            string real = Text.GetText(on);
                                                                                            var r = new SaneArrayList();
                                                                                            Pattern p = null;

                                                                                            if(args.Count == 0) {
                                                                                                p = new Pattern("\\s");
                                                                                            } else {
                                                                                                object arg = args[0];
                                                                                                if(IokeObject.dataOf(arg) is Regexp) {
                                                                                                    p = Regexp.GetRegexp(arg);
                                                                                                } else {
                                                                                                    string around = Text.GetText(arg);
                                                                                                    p = new Pattern(Pattern.Quote(around));
                                                                                                }
                                                                                            }

                                                                                            RETokenizer tok = new RETokenizer(p, real);
                                                                                            tok.EmptyEnabled = false;
                                                                                            while(tok.HasMore) {
                                                                                                r.Add(context.runtime.NewText(tok.NextToken));
                                                                                            }

                                                                                            return context.runtime.NewList(r);
                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Takes two text arguments where the first is the substring to replace, and the second is the replacement to insert. Will only replace the first match, if any is found, and return a new Text with the result.",
//.........这里部分代码省略.........
开发者ID:fronx,项目名称:ioke,代码行数:101,代码来源:Text.cs

示例6: GetOpTable

 public IDictionary GetOpTable(IokeObject opTable, string name, OpTableCreator creator)
 {
     IokeObject operators = IokeObject.As(opTable.FindCell(_message, _context, name), null);
     if(operators != runtime.nul && (IokeObject.dataOf(operators) is Dict)) {
         return Dict.GetMap(operators);
     } else {
         var result = creator.Create(runtime);
         opTable.SetCell(name, runtime.NewDict(result));
         return result;
     }
 }
开发者ID:fronx,项目名称:ioke,代码行数:11,代码来源:Levels.cs

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

示例8: Init

        public static void Init(IokeObject obj)
        {
            Runtime runtime = obj.runtime;
            obj.Kind = "DefaultBehavior";

            IokeObject baseBehavior = new IokeObject(runtime, "contains behavior copied from Base");
            baseBehavior.Kind = "DefaultBehavior BaseBehavior";
            baseBehavior.SetCell("=",         runtime.Base.body.Get("="));
            baseBehavior.SetCell("==",        runtime.Base.body.Get("=="));
            baseBehavior.SetCell("cell",      runtime.Base.body.Get("cell"));
            baseBehavior.SetCell("cell?",     runtime.Base.body.Get("cell?"));
            baseBehavior.SetCell("cell=",     runtime.Base.body.Get("cell="));
            baseBehavior.SetCell("cells",     runtime.Base.body.Get("cells"));
            baseBehavior.SetCell("cellNames", runtime.Base.body.Get("cellNames"));
            baseBehavior.SetCell("removeCell!", runtime.Base.body.Get("removeCell!"));
            baseBehavior.SetCell("undefineCell!", runtime.Base.body.Get("undefineCell!"));
            baseBehavior.SetCell("cellOwner?", runtime.Base.body.Get("cellOwner?"));
            baseBehavior.SetCell("cellOwner", runtime.Base.body.Get("cellOwner"));
            baseBehavior.SetCell("documentation", runtime.Base.body.Get("documentation"));
            baseBehavior.SetCell("identity", runtime.Base.body.Get("identity"));
            obj.MimicsWithoutCheck(baseBehavior);
            obj.RegisterCell("BaseBehavior", baseBehavior);

            IokeObject assignmentBehavior = new IokeObject(runtime, "contains behavior related to assignment");
            assignmentBehavior.MimicsWithoutCheck(baseBehavior);
            AssignmentBehavior.Init(assignmentBehavior);
            obj.MimicsWithoutCheck(assignmentBehavior);
            obj.RegisterCell("Assignment", assignmentBehavior);

            IokeObject internalBehavior = new IokeObject(runtime, "contains behavior related to internal functionality");
            internalBehavior.MimicsWithoutCheck(baseBehavior);
            InternalBehavior.Init(internalBehavior);
            obj.MimicsWithoutCheck(internalBehavior);
            obj.RegisterCell("Internal", internalBehavior);

            IokeObject flowControlBehavior = new IokeObject(runtime, "contains behavior related to flow control");
            flowControlBehavior.MimicsWithoutCheck(baseBehavior);
            FlowControlBehavior.Init(flowControlBehavior);
            obj.MimicsWithoutCheck(flowControlBehavior);
            obj.RegisterCell("FlowControl", flowControlBehavior);

            IokeObject definitionsBehavior = new IokeObject(runtime, "contains behavior related to the definition of different concepts");
            definitionsBehavior.MimicsWithoutCheck(baseBehavior);
            DefinitionsBehavior.Init(definitionsBehavior);
            obj.MimicsWithoutCheck(definitionsBehavior);
            obj.RegisterCell("Definitions", definitionsBehavior);

            IokeObject conditionsBehavior = new IokeObject(runtime, "contains behavior related to conditions");
            conditionsBehavior.MimicsWithoutCheck(baseBehavior);
            ConditionsBehavior.Init(conditionsBehavior);
            obj.MimicsWithoutCheck(conditionsBehavior);
            obj.RegisterCell("Conditions", conditionsBehavior);

            IokeObject literalsBehavior = new IokeObject(runtime, "contains behavior related to literals");
            literalsBehavior.MimicsWithoutCheck(baseBehavior);
            LiteralsBehavior.Init(literalsBehavior);
            obj.MimicsWithoutCheck(literalsBehavior);
            obj.RegisterCell("Literals", literalsBehavior);

            IokeObject caseBehavior = new IokeObject(runtime, "contains behavior related to the case statement");
            caseBehavior.MimicsWithoutCheck(baseBehavior);
            CaseBehavior.Init(caseBehavior);
            obj.MimicsWithoutCheck(caseBehavior);
            obj.RegisterCell("Case", caseBehavior);

            IokeObject reflectionBehavior = new IokeObject(runtime, "contains behavior related to reflection");
            reflectionBehavior.MimicsWithoutCheck(baseBehavior);
            ReflectionBehavior.Init(reflectionBehavior);
            obj.MimicsWithoutCheck(reflectionBehavior);
            obj.RegisterCell("Reflection", reflectionBehavior);

            IokeObject booleanBehavior = new IokeObject(runtime, "contains behavior related to boolean behavior");
            booleanBehavior.MimicsWithoutCheck(baseBehavior);
            booleanBehavior.Kind = "DefaultBehavior Boolean";
            obj.MimicsWithoutCheck(booleanBehavior);
            obj.RegisterCell("Boolean", booleanBehavior);

            IokeObject aspects = new IokeObject(runtime, "contains behavior related to aspects");
            aspects.MimicsWithoutCheck(baseBehavior);
            aspects.Kind = "DefaultBehavior Aspects";
            obj.MimicsWithoutCheck(aspects);
            obj.RegisterCell("Aspects", aspects);
        }
开发者ID:goking,项目名称:ioke,代码行数:83,代码来源:DefaultBehavior.cs

示例9: Init

        public override void Init(IokeObject obj)
        {
            obj.Kind = "Arity";

            obj.SetCell("taking:nothing", GetArity(obj, Taking.Nothing));
            obj.SetCell("taking:everything", GetArity(obj, Taking.Everything));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("Create an Arity object from the given messages. The list of unevaluated messages given to this method will be used as if they were the arguments part of a DefaultMethod definition.",
                                                           new TypeCheckingNativeMethod("from", TypeCheckingArgumentsDefinition.builder()
                                                                                        .ReceiverMustMimic(obj)
                                                                                        .WithRestUnevaluated("arguments")
                                                                                        .Arguments,
                                                                                        (self, on, args, keywords, context, message) => {
                                                                                            if (message.Arguments.Count == 0) {
                                                                                                return TakingNothing(self);
                                                                                            }
                                                                                            DefaultArgumentsDefinition def = DefaultArgumentsDefinition.CreateFrom(message.Arguments, 0, message.Arguments.Count, message, on, context);
                                                                                            return GetArity(self, def);
                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the names for positional arguments",
                                                           new TypeCheckingNativeMethod("positionals", TypeCheckingArgumentsDefinition.builder()
                                                                                        .WithOptionalPositional("includeOptionals", "true")
                                                                                        .Arguments,
                                                                                        (method, on, args, keywords, context, message) => {
                                                                                            Arity a = (Arity)IokeObject.dataOf(on);
                                                                                            var names = new SaneArrayList();
                                                                                            bool includeOptional = args.Count == 0 ? true : IokeObject.IsObjectTrue(args[0]);
                                                                                            if(a.argumentsDefinition != null) {
                                                                                                foreach(DefaultArgumentsDefinition.Argument argument in a.argumentsDefinition.Arguments) {
                                                                                                    if(argument is DefaultArgumentsDefinition.KeywordArgument) { continue; }
                                                                                                    if(argument is DefaultArgumentsDefinition.OptionalArgument) {
                                                                                                        if(includeOptional) {
                                                                                                            names.Add(method.runtime.GetSymbol(argument.Name));
                                                                                                        }
                                                                                                    } else {
                                                                                                        names.Add(method.runtime.GetSymbol(argument.Name));
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            return method.runtime.NewList(names);
                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the names for keyword arguments",
                                                           new TypeCheckingNativeMethod.WithNoArguments("keywords", obj,
                                                                                                        (method, on, args, keywords, context, message) => {
                                                                                                            Arity a = (Arity)IokeObject.dataOf(on);
                                                                                                            var names = new SaneArrayList();
                                                                                                            if(a.argumentsDefinition != null) {
                                                                                                                foreach(string name in a.argumentsDefinition.Keywords) {
                                                                                                                    names.Add(method.runtime.GetSymbol(name.Substring(0, name.Length - 1)));
                                                                                                                }
                                                                                                            }
                                                                                                            return method.runtime.NewList(names);
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the symbol name for the krest argument.",
                                                           new TypeCheckingNativeMethod.WithNoArguments("krest", obj,
                                                                                                        (method, on, args, keywords, context, message) => {
                                                                                                            Arity a = (Arity)IokeObject.dataOf(on);
                                                                                                            if(a.argumentsDefinition != null) {
                                                                                                                string name = a.argumentsDefinition.KrestName;
                                                                                                                if(name == null) {
                                                                                                                    return method.runtime.nil;
                                                                                                                } else {
                                                                                                                    return method.runtime.GetSymbol(name);
                                                                                                                }
                                                                                                            } else {
                                                                                                                return method.runtime.nil;
                                                                                                            }
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the symbol name for the rest argument.",
                                                           new TypeCheckingNativeMethod.WithNoArguments("rest", obj,
                                                                                                        (method, on, args, keywords, context, message) => {
                                                                                                            Arity a = (Arity)IokeObject.dataOf(on);
                                                                                                            if(a.argumentsDefinition != null) {
                                                                                                                string name = a.argumentsDefinition.RestName;
                                                                                                                if(name == null) {
                                                                                                                    return method.runtime.nil;
                                                                                                                } else {
                                                                                                                    return method.runtime.GetSymbol(name);
                                                                                                                }
                                                                                                            } else {
                                                                                                                return method.runtime.nil;
                                                                                                            }
                                                                                                        })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the text representation of this arity",
                                                           new TypeCheckingNativeMethod.WithNoArguments("asText", obj,
                                                                                                        (method, on, args, keywords, context, message) => {
                                                                                                            Arity a = (Arity) IokeObject.dataOf(on);
                                                                                                            if (a.taking == Taking.Everything) {
                                                                                                                return method.runtime.NewText("...");
                                                                                                            } else if (a.taking == Taking.Nothing) {
                                                                                                                return method.runtime.NewText("");
                                                                                                            }
                                                                                                            return method.runtime.NewText(a.argumentsDefinition.GetCode(false));
                                                                                                        })));
        }
开发者ID:fronx,项目名称:ioke,代码行数:100,代码来源:Arity.cs

示例10: Init

        public static void Init(IokeObject obj)
        {
            Runtime runtime = obj.runtime;
            obj.Kind = "DefaultBehavior";

            IokeObject baseBehavior = new IokeObject(runtime, "contains behavior copied from Base");
            baseBehavior.Kind = "DefaultBehavior BaseBehavior";
            baseBehavior.SetCell("=",         runtime.Base.Cells["="]);
            baseBehavior.SetCell("==",        runtime.Base.Cells["=="]);
            baseBehavior.SetCell("cell",      runtime.Base.Cells["cell"]);
            baseBehavior.SetCell("cell?",     runtime.Base.Cells["cell?"]);
            baseBehavior.SetCell("cell=",     runtime.Base.Cells["cell="]);
            baseBehavior.SetCell("cells",     runtime.Base.Cells["cells"]);
            baseBehavior.SetCell("cellNames", runtime.Base.Cells["cellNames"]);
            baseBehavior.SetCell("removeCell!", runtime.Base.Cells["removeCell!"]);
            baseBehavior.SetCell("undefineCell!", runtime.Base.Cells["undefineCell!"]);
            baseBehavior.SetCell("cellOwner?", runtime.Base.Cells["cellOwner?"]);
            baseBehavior.SetCell("cellOwner", runtime.Base.Cells["cellOwner"]);
            baseBehavior.SetCell("documentation", runtime.Base.Cells["documentation"]);
            baseBehavior.SetCell("identity", runtime.Base.Cells["identity"]);
            obj.MimicsWithoutCheck(baseBehavior);
            obj.RegisterCell("BaseBehavior", baseBehavior);

            IokeObject assignmentBehavior = new IokeObject(runtime, "contains behavior related to assignment");
            assignmentBehavior.MimicsWithoutCheck(baseBehavior);
            AssignmentBehavior.Init(assignmentBehavior);
            obj.MimicsWithoutCheck(assignmentBehavior);
            obj.RegisterCell("Assignment", assignmentBehavior);

            IokeObject internalBehavior = new IokeObject(runtime, "contains behavior related to internal functionality");
            internalBehavior.MimicsWithoutCheck(baseBehavior);
            InternalBehavior.Init(internalBehavior);
            obj.MimicsWithoutCheck(internalBehavior);
            obj.RegisterCell("Internal", internalBehavior);

            IokeObject flowControlBehavior = new IokeObject(runtime, "contains behavior related to flow control");
            flowControlBehavior.MimicsWithoutCheck(baseBehavior);
            FlowControlBehavior.Init(flowControlBehavior);
            obj.MimicsWithoutCheck(flowControlBehavior);
            obj.RegisterCell("FlowControl", flowControlBehavior);

            IokeObject definitionsBehavior = new IokeObject(runtime, "contains behavior related to the definition of different concepts");
            definitionsBehavior.MimicsWithoutCheck(baseBehavior);
            DefinitionsBehavior.Init(definitionsBehavior);
            obj.MimicsWithoutCheck(definitionsBehavior);
            obj.RegisterCell("Definitions", definitionsBehavior);

            IokeObject conditionsBehavior = new IokeObject(runtime, "contains behavior related to conditions");
            conditionsBehavior.MimicsWithoutCheck(baseBehavior);
            ConditionsBehavior.Init(conditionsBehavior);
            obj.MimicsWithoutCheck(conditionsBehavior);
            obj.RegisterCell("Conditions", conditionsBehavior);

            IokeObject literalsBehavior = new IokeObject(runtime, "contains behavior related to literals");
            literalsBehavior.MimicsWithoutCheck(baseBehavior);
            LiteralsBehavior.Init(literalsBehavior);
            obj.MimicsWithoutCheck(literalsBehavior);
            obj.RegisterCell("Literals", literalsBehavior);

            IokeObject caseBehavior = new IokeObject(runtime, "contains behavior related to the case statement");
            caseBehavior.MimicsWithoutCheck(baseBehavior);
            CaseBehavior.Init(caseBehavior);
            obj.MimicsWithoutCheck(caseBehavior);
            obj.RegisterCell("Case", caseBehavior);

            IokeObject reflectionBehavior = new IokeObject(runtime, "contains behavior related to reflection");
            reflectionBehavior.MimicsWithoutCheck(baseBehavior);
            ReflectionBehavior.Init(reflectionBehavior);
            obj.MimicsWithoutCheck(reflectionBehavior);
            obj.RegisterCell("Reflection", reflectionBehavior);

            IokeObject booleanBehavior = new IokeObject(runtime, "contains behavior related to boolean behavior");
            booleanBehavior.MimicsWithoutCheck(baseBehavior);
            booleanBehavior.Kind = "DefaultBehavior Boolean";
            obj.MimicsWithoutCheck(booleanBehavior);
            obj.RegisterCell("Boolean", booleanBehavior);

            IokeObject aspects = new IokeObject(runtime, "contains behavior related to aspects");
            aspects.MimicsWithoutCheck(baseBehavior);
            aspects.Kind = "DefaultBehavior Aspects";
            obj.MimicsWithoutCheck(aspects);
            obj.RegisterCell("Aspects", aspects);

            obj.RegisterMethod(runtime.NewNativeMethod("takes one or more evaluated string argument. will import the files corresponding to each of the strings named based on the Ioke loading behavior that can be found in the documentation for the loadBehavior cell on System.",
                                                       new NativeMethod("use", DefaultArgumentsDefinition.builder()
                                                                        .WithOptionalPositional("module", "false")
                                                                        .Arguments,
                                                                        (method, context, message, on, outer) => {
                                                                            IList args = new SaneArrayList();
                                                                            outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, new SaneDictionary<string, object>());
                                                                            if(args.Count == 0) {
                                                                                return method;
                                                                            }

                                                                            string name = Text.GetText(((Message)IokeObject.dataOf(runtime.asText)).SendTo(runtime.asText, context, args[0]));
                                                                            if(((IokeSystem)IokeObject.dataOf(runtime.System)).Use(IokeObject.As(on, context), context, message, name)) {
                                                                                return runtime.True;
                                                                            } else {
                                                                                return runtime.False;
                                                                            }
//.........这里部分代码省略.........
开发者ID:vic,项目名称:ioke-outdated,代码行数:101,代码来源:DefaultBehavior.cs


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