Example #1
0
 public AliasMethod(string name, IokeData realMethod, IokeObject realSelf)
     : base(IokeData.TYPE_ALIAS_METHOD)
 {
     this.name = name;
     this.realMethod = realMethod;
     this.realSelf = realSelf;
 }
Example #2
0
        public override void Init(IokeObject obj)
        {
            obj.Kind = "Method";
            obj.SetActivatable(true);

            obj.RegisterMethod(obj.runtime.NewNativeMethod("activates this method with the arguments given to call",
                                                           new NativeMethod("call", DefaultArgumentsDefinition.builder()
                                                                            .WithRestUnevaluated("arguments")
                                                                            .Arguments,
                                                                            (method, _context, message, on, outer) => {
                return(Interpreter.Activate(IokeObject.As(on, _context), _context, message, _context.RealContext));
            })));

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the name of the method",
                                                           new TypeCheckingNativeMethod.WithNoArguments("name", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                return(_context.runtime.NewText(((Method)IokeObject.dataOf(on)).name));
            })));

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

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

            obj.RegisterMethod(obj.runtime.NewNativeMethod("returns the full code of this method, as a Text",
                                                           new TypeCheckingNativeMethod.WithNoArguments("code", obj,
                                                                                                        (method, on, args, keywords, _context, message) => {
                IokeData data = IokeObject.dataOf(on);
                if (data is Method)
                {
                    return(_context.runtime.NewText(((Method)data).CodeString));
                }
                else
                {
                    return(_context.runtime.NewText(((AliasMethod)data).CodeString));
                }
            })));
        }
Example #3
0
        public new static object ActivateFixed(IokeObject self, IokeObject ctx, IokeObject message, object obj)
        {
            AliasMethod am       = (AliasMethod)self.data;
            IokeObject  realSelf = am.realSelf;

            switch (am.realMethod.type)
            {
            case IokeData.TYPE_DEFAULT_METHOD:
                return(DefaultMethod.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_DEFAULT_MACRO:
                return(DefaultMacro.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_DEFAULT_SYNTAX:
                return(DefaultSyntax.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_LEXICAL_MACRO:
                return(LexicalMacro.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_NATIVE_METHOD:
                return(NativeMethod.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_METHOD_PROTOTYPE:
                return(Method.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_LEXICAL_BLOCK:
                return(LexicalBlock.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_ALIAS_METHOD:
                return(AliasMethod.ActivateFixed(realSelf, ctx, message, obj));

            case IokeData.TYPE_NONE:
            default:
                return(IokeData.ActivateFixed(realSelf, ctx, message, obj));
            }
        }
Example #4
0
 public AliasMethod(string name, IokeData realMethod, IokeObject realSelf)
 {
     this.name = name;
     this.realMethod = realMethod;
     this.realSelf = realSelf;
 }
Example #5
0
 public AliasMethod(string name, IokeData realMethod, IokeObject realSelf) : base(IokeData.TYPE_ALIAS_METHOD)
 {
     this.name       = name;
     this.realMethod = realMethod;
     this.realSelf   = realSelf;
 }