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


C# Lang.IokeObject类代码示例

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


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

示例1: LexicalBlock

 public LexicalBlock(IokeObject context, DefaultArgumentsDefinition arguments, IokeObject message)
     : base(IokeData.TYPE_LEXICAL_BLOCK)
 {
     this.context = context;
     this.arguments = arguments;
     this.message = message;
 }
开发者ID:goking,项目名称:ioke,代码行数:7,代码来源:LexicalBlock.cs

示例2: ActivateWithCallAndDataFixed

        public static object ActivateWithCallAndDataFixed(IokeObject self, IokeObject dynamicContext, IokeObject message, object on, object call, IDictionary<string, object> data)
        {
            LexicalMacro lm = (LexicalMacro)self.data;
            if(lm.code == null) {
                IokeObject condition = IokeObject.As(IokeObject.GetCellChain(dynamicContext.runtime.Condition,
                                                                             message,
                                                                             dynamicContext,
                                                                             "Error",
                                                                             "Invocation",
                                                                             "NotActivatable"), dynamicContext).Mimic(message, dynamicContext);
                condition.SetCell("message", message);
                condition.SetCell("context", dynamicContext);
                condition.SetCell("receiver", on);
                condition.SetCell("method", self);
                condition.SetCell("report", dynamicContext.runtime.NewText("You tried to activate a method without any code - did you by any chance activate the LexicalMacro kind by referring to it without wrapping it inside a call to cell?"));
                dynamicContext.runtime.ErrorCondition(condition);
                return null;
            }

            IokeObject c = self.runtime.NewLexicalContext(on, "Lexical macro activation context", lm.context);

            c.SetCell("outerScope", lm.context);
            c.SetCell("call", call);
            foreach(var d in data) {
                string s = d.Key;
                c.SetCell(s.Substring(0, s.Length-1), d.Value);
            }

            return self.runtime.interpreter.Evaluate(lm.code, c, on, c);
        }
开发者ID:goking,项目名称:ioke,代码行数:30,代码来源:LexicalMacro.cs

示例3: Call

 public Call(IokeObject ctx, IokeObject message, IokeObject surroundingContext, IokeObject on)
 {
     this.ctx = ctx;
     this.message = message;
     this.surroundingContext = surroundingContext;
     this.on = on;
 }
开发者ID:fronx,项目名称:ioke,代码行数:7,代码来源:Call.cs

示例4: ActivateFixed

        public static new object ActivateFixed(IokeObject self, IokeObject dynamicContext, IokeObject message, object on)
        {
            LexicalMacro lm = (LexicalMacro)self.data;
            if(lm.code == null) {
                IokeObject condition = IokeObject.As(IokeObject.GetCellChain(dynamicContext.runtime.Condition,
                                                                             message,
                                                                             dynamicContext,
                                                                             "Error",
                                                                             "Invocation",
                                                                             "NotActivatable"), dynamicContext).Mimic(message, dynamicContext);
                condition.SetCell("message", message);
                condition.SetCell("context", dynamicContext);
                condition.SetCell("receiver", on);
                condition.SetCell("method", self);
                condition.SetCell("report", dynamicContext.runtime.NewText("You tried to activate a method without any code - did you by any chance activate the LexicalMacro kind by referring to it without wrapping it inside a call to cell?"));
                dynamicContext.runtime.ErrorCondition(condition);
                return null;
            }

            IokeObject c = self.runtime.NewLexicalContext(on, "Lexical macro activation context", lm.context);

            c.SetCell("outerScope", lm.context);
            c.SetCell("call", dynamicContext.runtime.NewCallFrom(c, message, dynamicContext, IokeObject.As(on, dynamicContext)));

            return self.runtime.interpreter.Evaluate(lm.code, c, on, c);
        }
开发者ID:goking,项目名称:ioke,代码行数:26,代码来源:LexicalMacro.cs

示例5: Init

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

            obj.Kind = "DateTime";
            //        obj.mimics(IokeObject.as(runtime.mixins.getCell(null, null, "Comparing")), runtime.nul, runtime.nul);

            obj.RegisterMethod(runtime.NewNativeMethod("Returns a new DateTime representing the current instant in time in the default TimeZone.",
                                                       new TypeCheckingNativeMethod.WithNoArguments("now", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return method.runtime.NewDateTime(System.DateTime.Now);
                                                                                                    })));

            obj.RegisterMethod(runtime.NewNativeMethod("Expects to get one DateTime as argument, and returns the difference between this instant and that instant, in milliseconds.",
                                                       new TypeCheckingNativeMethod("-", TypeCheckingArgumentsDefinition.builder()
                                                                                    .ReceiverMustMimic(obj)
                                                                                    .WithRequiredPositional("subtrahend").WhichMustMimic(obj)
                                                                                    .Arguments,
                                                                                    (method, on, args, keywords, context, message) => {
                                                                                        long diff = System.Convert.ToInt64(GetDateTime(on).Subtract(GetDateTime(args[0])).TotalMilliseconds);
                                                                                        return context.runtime.NewNumber(diff);
                                                                                    })));

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

            obj.RegisterMethod(runtime.NewNativeMethod("Returns a brief text inspection of the object",
                                                       new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return method.runtime.NewText(DateTime.GetNotice(on));
                                                                                                    })));
        }
开发者ID:fronx,项目名称:ioke,代码行数:35,代码来源:DateTime.cs

示例6: Level

 internal Level(int precedence, IokeObject op, Level parent, Type type)
 {
     this.precedence = precedence;
     this.operatorMessage = op;
     this.parent = parent;
     this.type = type;
 }
开发者ID:nope,项目名称:ioke,代码行数:7,代码来源:Level.cs

示例7: ToRational

        public static object ToRational(object on, IokeObject context, IokeObject message)
        {
            string tvalue = GetText(on);
            try {
                return context.runtime.NewNumber(tvalue);
            } catch(Exception) {
                Runtime runtime = context.runtime;
                IokeObject condition = IokeObject.As(IokeObject.GetCellChain(runtime.Condition,
                                                                             message,
                                                                             context,
                                                                             "Error",
                                                                             "Arithmetic",
                                                                             "NotParseable"), context).Mimic(message, context);
                condition.SetCell("message", message);
                condition.SetCell("context", context);
                condition.SetCell("receiver", on);
                condition.SetCell("text", on);

                object[] newCell = new object[]{null};

                runtime.WithRestartReturningArguments(()=>{runtime.ErrorCondition(condition);},
                                                      context,
                                                      new IokeObject.UseValue("rational", newCell),
                                                      new TakeLongestRational(tvalue, newCell));
                return newCell[0];
            }
        }
开发者ID:fronx,项目名称:ioke,代码行数:27,代码来源:Text.cs

示例8: ArgumentActivator

 private static object ArgumentActivator(IokeObject self, IokeObject context, IokeObject message, object on, NativeMethod outer)
 {
     IList args = new SaneArrayList();
     IDictionary<string, object> keywords = new SaneDictionary<string, object>();
     outer.ArgumentsDefinition.GetEvaluatedArguments(context, message, on, args, keywords);
     return outer.argsActivator(self, on, args, keywords, context, message);
 }
开发者ID:fronx,项目名称:ioke,代码行数:7,代码来源:NativeMethod.cs

示例9: Range

 public Range(IokeObject from, IokeObject to, bool inclusive, bool inverted)
 {
     this.from = from;
     this.to = to;
     this.inclusive = inclusive;
     this.inverted = inverted;
 }
开发者ID:goking,项目名称:ioke,代码行数:7,代码来源:Range.cs

示例10: Activate

        public override object Activate(IokeObject self, IokeObject dynamicContext, IokeObject message, object on)
        {
            if(code == null) {
                IokeObject condition = IokeObject.As(IokeObject.GetCellChain(dynamicContext.runtime.Condition,
                                                                             message,
                                                                             dynamicContext,
                                                                             "Error",
                                                                             "Invocation",
                                                                             "NotActivatable"), dynamicContext).Mimic(message, dynamicContext);
                condition.SetCell("message", message);
                condition.SetCell("context", dynamicContext);
                condition.SetCell("receiver", on);
                condition.SetCell("method", self);
                condition.SetCell("report", dynamicContext.runtime.NewText("You tried to activate a method without any code - did you by any chance activate the LexicalMacro kind by referring to it without wrapping it inside a call to cell?"));
                dynamicContext.runtime.ErrorCondition(condition);
                return null;
            }

            LexicalContext c = new LexicalContext(self.runtime, on, "Lexical macro activation context", message, this.context);

            c.SetCell("outerScope", context);
            c.SetCell("call", dynamicContext.runtime.NewCallFrom(c, message, dynamicContext, IokeObject.As(on, dynamicContext)));

            return ((Message)IokeObject.dataOf(this.code)).EvaluateCompleteWith(this.code, c, on);
        }
开发者ID:fronx,项目名称:ioke,代码行数:25,代码来源:LexicalMacro.cs

示例11: TypeCheckingRawActivate

 private static object TypeCheckingRawActivate(IokeObject self, IokeObject context, IokeObject message, object on, NativeMethod outer)
 {
     IList args = new SaneArrayList();
     IDictionary<string, object> keywords = new SaneDictionary<string, object>();
     object receiver = ((TypeCheckingArgumentsDefinition)outer.ArgumentsDefinition).GetValidatedArgumentsAndReceiver(context, message, on, args, keywords);
     return outer.argsActivator(self, receiver, args, keywords, context, message);
 }
开发者ID:fronx,项目名称:ioke,代码行数:7,代码来源:TypeCheckingNativeMethod.cs

示例12: IokeParser

 public IokeParser(Runtime runtime, TextReader reader, IokeObject context, IokeObject message)
 {
     this.runtime = runtime;
     this.reader = reader;
     this.context = context;
     this.message = message;
 }
开发者ID:vic,项目名称:ioke-outdated,代码行数:7,代码来源:IokeParser.cs

示例13: GetValidatedArgumentsAndReceiver

        public object GetValidatedArgumentsAndReceiver(IokeObject context, IokeObject message, object on, IList argumentsWithoutKeywords, IDictionary<string, object> givenKeywords)
        {
            if(!restUneval) {
                GetEvaluatedArguments(context, message, on, argumentsWithoutKeywords, givenKeywords);
                int ix = 0;
                for (int i = 0, j = this.arguments.Count; i < j; i++) {
                    Argument a = this.arguments[i];

                    if (a is KeywordArgument) {
                        string name = a.Name + ":";
                        object given = givenKeywords[name];
                        if (given != null) {
                            givenKeywords[name] = mustMimic[0].ConvertToMimic(given, message, context, true);
                        }
                    } else {
                        if(ix < argumentsWithoutKeywords.Count) {
                            argumentsWithoutKeywords[ix] = mustMimic[i].ConvertToMimic(argumentsWithoutKeywords[ix], message, context, true);
                            ix++;
                        }
                    }
                }
            } else {
                foreach(object o in message.Arguments) argumentsWithoutKeywords.Add(o);
            }
            return receiverMustMimic.ConvertToMimic(on, message, context, true);
        }
开发者ID:vic,项目名称:ioke-outdated,代码行数:26,代码来源:TypeCheckingArgumentsDefinition.cs

示例14: Init

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

            obj.Kind = "Pair";
            obj.Mimics(IokeObject.As(runtime.Mixins.GetCell(null, null, "Enumerable"), null), runtime.nul, runtime.nul);
            obj.Mimics(IokeObject.As(runtime.Mixins.GetCell(null, null, "Comparing"), null), runtime.nul, runtime.nul);

            obj.RegisterMethod(runtime.NewNativeMethod("returns true if the left hand side pair is equal to the right hand side pair.",
                                                       new TypeCheckingNativeMethod("==", TypeCheckingArgumentsDefinition.builder()
                                                                                    .ReceiverMustMimic(runtime.Pair)
                                                                                    .WithRequiredPositional("other")
                                                                                    .Arguments,
                                                                                    (method, on, args, keywords, context, message) => {
                                                                                        Pair d = (Pair)IokeObject.dataOf(on);
                                                                                        object other = args[0];

                                                                                        return ((other is IokeObject) &&
                                                                                                (IokeObject.dataOf(other) is Pair)
                                                                                                && d.first.Equals(((Pair)IokeObject.dataOf(other)).first)
                                                                                                && d.second.Equals(((Pair)IokeObject.dataOf(other)).second)) ? context.runtime.True : context.runtime.False;
                                                                                    })));

            obj.RegisterMethod(runtime.NewNativeMethod("Returns the first value",
                                                       new TypeCheckingNativeMethod.WithNoArguments("first", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return ((Pair)IokeObject.dataOf(on)).first;
                                                                                                    })));

            obj.RegisterMethod(runtime.NewNativeMethod("Returns the first value",
                                                       new TypeCheckingNativeMethod.WithNoArguments("key", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return ((Pair)IokeObject.dataOf(on)).first;
                                                                                                    })));

            obj.RegisterMethod(runtime.NewNativeMethod("Returns the second value",
                                                       new TypeCheckingNativeMethod.WithNoArguments("second", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return ((Pair)IokeObject.dataOf(on)).second;
                                                                                                    })));

            obj.RegisterMethod(runtime.NewNativeMethod("Returns the second value",
                                                       new TypeCheckingNativeMethod.WithNoArguments("value", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return ((Pair)IokeObject.dataOf(on)).second;
                                                                                                    })));

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

            obj.RegisterMethod(runtime.NewNativeMethod("Returns a brief text inspection of the object",
                                                       new TypeCheckingNativeMethod.WithNoArguments("notice", obj,
                                                                                                    (method, on, args, keywords, context, message) => {
                                                                                                        return method.runtime.NewText(Pair.GetNotice(on));
                                                                                                    })));
        }
开发者ID:vic,项目名称:ioke-outdated,代码行数:59,代码来源:Pair.cs

示例15: GetContextMessageName

 public static string GetContextMessageName(IokeObject ctx)
 {
     if("Locals".Equals(ctx.GetKind())) {
         return ":in `" + IokeObject.As(ctx.Cells["currentMessage"], ctx).Name + "'";
     } else {
         return "";
     }
 }
开发者ID:vic,项目名称:ioke-outdated,代码行数:8,代码来源:Locals.cs


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