Exemplo n.º 1
0
        private KecaknoahReference find, each, filter, map, reduce;//, first, last;

        internal KecaknoahArray(int[] dim)
        {
            Type      = TypeCode.Object;
            ExtraType = "Array";
            array     = new List <KecaknoahReference>();
            length    = KecaknoahReference.CreateRightReference(dim[0]);
            InitializeMembers();
            for (int i = 0; i < dim[0]; i++)
            {
                array.Add(new KecaknoahReference {
                    IsLeftValue = true, RawObject = KecaknoahNil.Instance
                });
            }
            if (dim.Length == 1)
            {
                return;
            }
            for (int i = 0; i < array.Count; i++)
            {
                array[i] = new KecaknoahReference {
                    IsLeftValue = true, RawObject = new KecaknoahArray(dim.Skip(1).ToArray())
                }
            }
            ;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 要素を指定して新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="refs">追加する要素</param>
 public KecaknoahList(IEnumerable <KecaknoahObject> refs) : base()
 {
     foreach (var i in refs)
     {
         list.Add(KecaknoahReference.Left(i));
     }
 }
Exemplo n.º 3
0
 internal KecaknoahArray(List <KecaknoahReference> arr)
 {
     Type   = TypeCode.Object;
     array  = arr;
     length = KecaknoahReference.Right(arr.Count);
     InitializeMembers();
 }
Exemplo n.º 4
0
 internal KecaknoahDynamicType(System.Type t)
 {
     ExtraType = ClassName;
     type = t;
     name = KecaknoahReference.Right(type.Name);
     create_instance = KecaknoahReference.Right(new KecaknoahInteropFunction(this, InstanceCreareInstance));
 }
Exemplo n.º 5
0
        private KecaknoahFunctionResult InstanceAddRange(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args)
        {
            var al = args[0].AsArray();

            list.AddRange(al.Select(p => KecaknoahReference.Left(p)));
            return(KecaknoahNil.Instance.NoResume());
        }
Exemplo n.º 6
0
 internal KecaknoahArray(List<KecaknoahReference> arr)
 {
     Type = TypeCode.Object;
     array = arr;
     length = KecaknoahReference.CreateRightReference(arr.Count);
     InitializeMembers();
 }
Exemplo n.º 7
0
 /// <summary>
 /// 特定の<see cref="KecaknoahScriptClassInfo"/>を元にして、インスタンスを生成します。
 /// コンストラクタがあった場合、呼び出します。
 /// </summary>
 /// <param name="klass">クラス</param>
 /// <param name="ctx">コンテキスト</param>
 /// <param name="ctorArgs">コンストラクタ引数</param>
 public KecaknoahInstance(KecaknoahScriptClassInfo klass, KecaknoahContext ctx, KecaknoahObject[] ctorArgs)
 {
     Class = klass;
     LocalFieldReferences     = localReferences;
     InstanceMethodReferences = methodReferences;
     foreach (var i in klass.Locals)
     {
         localReferences[i] = new KecaknoahReference()
         {
             IsLeftValue = true
         }
     }
     ;
     foreach (var i in klass.methods)
     {
         methodReferences[i.Name] = new KecaknoahReference()
         {
             IsLeftValue = true,
             RawObject   = new KecaknoahScriptFunction(this, i)
         }
     }
     ;
     if (klass.classMethods.Any(p => p.Name == "new"))
     {
         var ctor = klass.classMethods.First(p => p.Name == "new");
         new KecaknoahScriptFunction(this, ctor).Call(ctx, ctorArgs);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 指定された名前のメンバーへの参照を取得します。
        /// 「参照」というのは右辺値・左辺値どちらにもなりうる<see cref="KecaknoahReference"/>を差し、
        /// インスタンスごとに1つずつ(呼ばれる毎にnewしない)である必要があります。
        /// ここで返されるべき参照は
        /// ・インスタンスメソッド
        /// ・プロパティ
        /// などです。どちらもフィールドに<see cref="KecaknoahReference"/>のインスタンスを確保して
        /// switch分岐でそれらを返すことが推奨されます。
        /// </summary>
        /// <param name="name">メンバー名</param>
        /// <returns></returns>
        protected internal override KecaknoahReference GetMemberReference(string name)
        {
            switch (name)
            {
            case nameof(add): return(add);

            case nameof(add_range): return(add_range);

            case nameof(insert): return(insert);

            case nameof(each): return(each);

            case nameof(remove_at): return(remove_at);

            case nameof(remove_by): return(remove_by);

            case nameof(map): return(map);

            case nameof(reduce): return(reduce);

            case nameof(filter): return(filter);

            case "length": return(KecaknoahReference.Right(list.Count));
            }
            return(base.GetMemberReference(name));
        }
Exemplo n.º 9
0
 private void InitializeMembers()
 {
     each   = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceEach));
     find   = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFind));
     filter = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFilter));
     map    = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceMap));
     reduce = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceReduce));
 }
Exemplo n.º 10
0
 private void InitializeMembers()
 {
     each   = KecaknoahReference.Right(this, InstanceEach);
     find   = KecaknoahReference.Right(this, InstanceFind);
     filter = KecaknoahReference.Right(this, InstanceFilter);
     map    = KecaknoahReference.Right(this, InstanceMap);
     reduce = KecaknoahReference.Right(this, InstanceReduce);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 配列の新しいインスタンスを生成します。
 /// </summary>
 /// <param name="arr">生成する対象の<see cref="KecaknoahObject"/>のリスト</param>
 public KecaknoahArray(IEnumerable<KecaknoahObject> arr)
 {
     Type = TypeCode.Object;
     array = new List<KecaknoahReference>();
     foreach (var i in arr) array.Add(KecaknoahReference.Left(i));
     length = KecaknoahReference.Right(arr.Count());
     InitializeMembers();
 }
Exemplo n.º 12
0
 /// <summary>
 /// インデクサーの参照を得ます。
 /// <see cref="GetMemberReference(string)"/>と<see cref="KecaknoahObject.Call(KecaknoahContext, KecaknoahObject[])"/>の
 /// 中間のような存在です。
 /// </summary>
 /// <param name="indices">インデックス</param>
 /// <returns>返す参照</returns>
 protected internal override KecaknoahReference GetIndexerReference(KecaknoahObject[] indices)
 {
     if (!dict.ContainsKey(indices[0]))
     {
         dict[indices[0]] = KecaknoahReference.Left(KecaknoahNil.Instance);
     }
     return(dict[indices[0]]);
 }
Exemplo n.º 13
0
 private void InitializeMembers()
 {
     each = KecaknoahReference.Right(this, InstanceEach);
     find = KecaknoahReference.Right(this, InstanceFind);
     filter = KecaknoahReference.Right(this, InstanceFilter);
     map = KecaknoahReference.Right(this, InstanceMap);
     reduce = KecaknoahReference.Right(this, InstanceReduce);
 }
Exemplo n.º 14
0
 private void InitializeMembers()
 {
     each = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceEach));
     find = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFind));
     filter = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFilter));
     map = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceMap));
     reduce = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceReduce));
 }
Exemplo n.º 15
0
 internal KecaknoahArray(List<KecaknoahObject> arr)
 {
     Type = TypeCode.Object;
     array = new List<KecaknoahReference>();
     foreach (var i in arr) array.Add(new KecaknoahReference { IsLeftValue = true, RawObject = i });
     length = KecaknoahReference.CreateRightReference(arr.Count);
     InitializeMembers();
 }
Exemplo n.º 16
0
 /// <summary>
 /// 新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="info"></param>
 public KecaknoahInteropClassObject(KecaknoahInteropClassInfo info)
 {
     Class = info;
     foreach (var i in Class.classMethods)
     {
         methods[i.Name] = (KecaknoahReference.Right(KecaknoahNil.Instance, i.Body));
     }
 }
Exemplo n.º 17
0
 protected internal override KecaknoahReference GetMemberReference(string name)
 {
     if (!members.ContainsKey(name))
     {
         members[name] = new KecaknoahReference { IsLeftValue = true, RawObject = KecaknoahNil.Instance };
     }
     return members[name];
 }
Exemplo n.º 18
0
 private KecaknoahFunctionResult InstanceAdd(KecaknoahContext ctx, KecaknoahObject self, KecaknoahObject[] args)
 {
     foreach (var i in args)
     {
         list.Add(KecaknoahReference.Left(i));
     }
     return(KecaknoahNil.Instance.NoResume());
 }
Exemplo n.º 19
0
 /// <summary>
 /// 新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="info"></param>
 public KecaknoahScriptClassObject(KecaknoahScriptClassInfo info)
 {
     Class = info;
     Constructor = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, CreateInstance));
     foreach (var i in Class.classMethods)
     {
         methods[i.Name] = (KecaknoahReference.CreateRightReference(new KecaknoahScriptFunction(KecaknoahNil.Instance, i)));
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// 新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="info"></param>
 public KecaknoahScriptClassObject(KecaknoahScriptClassInfo info)
 {
     Class       = info;
     Constructor = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, CreateInstance));
     foreach (var i in Class.classMethods)
     {
         methods[i.Name] = (KecaknoahReference.CreateRightReference(new KecaknoahScriptFunction(KecaknoahNil.Instance, i)));
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// 新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="info"></param>
 public KecaknoahScriptClassObject(KecaknoahScriptClassInfo info)
 {
     Class       = info;
     ExtraType   = "ScriptClass";
     Constructor = KecaknoahReference.Right(this, CreateInstance);
     foreach (var i in Class.classMethods)
     {
         methods[i.Name] = (KecaknoahReference.Right(new KecaknoahScriptFunction(KecaknoahNil.Instance, i)));
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// インデクサーの参照を得ます。
 /// <see cref="GetMemberReference(string)"/>と<see cref="KecaknoahObject.Call(KecaknoahContext, KecaknoahObject[])"/>の
 /// 中間のような存在です。
 /// </summary>
 /// <param name="indices">インデックス</param>
 /// <returns>返す参照</returns>
 protected internal override KecaknoahReference GetIndexerReference(KecaknoahObject[] indices)
 {
     if (!dict.ContainsKey(indices[0]))
     {
         dict[indices[0]] = new KecaknoahReference {
             IsLeftValue = true
         };
     }
     return(dict[indices[0]]);
 }
Exemplo n.º 23
0
 /// <summary>
 /// 新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="info"></param>
 public KecaknoahScriptClassObject(KecaknoahScriptClassInfo info)
 {
     Class = info;
     ExtraType = "ScriptClass";
     Constructor = KecaknoahReference.Right(this, CreateInstance);
     foreach (var i in Class.classMethods)
     {
         methods[i.Name] = (KecaknoahReference.Right(new KecaknoahScriptFunction(KecaknoahNil.Instance, i)));
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// 呼び出します。
        /// </summary>
        /// <param name="context"></param>
        /// <param name="args">引数</param>
        /// <returns>返り値</returns>
        protected internal override KecaknoahFunctionResult Call(KecaknoahContext context, KecaknoahObject[] args)
        {
            var sf = new KecaknoahStackFrame(context, BaseMethod.Codes);

            sf.Locals["self"] = KecaknoahReference.CreateRightReference(Instance);
            sf.Arguments      = args;
            var r = sf.Resume();

            return(new KecaknoahFunctionResult(sf.ReturningObject, r));
        }
Exemplo n.º 25
0
        /// <summary>
        /// メソッドを登録します。
        /// </summary>
        /// <param name="name">メソッド名</param>
        /// <param name="func">
        /// 登録するメソッドのデリゲート。
        /// インスタンスと引数配列が渡されます。
        /// </param>
        public void AddFunction(string name, Action <KecaknoahObject, KecaknoahObject[]> func)
        {
            KecaknoahInteropDelegate wp =
                (c, s, a) =>
            {
                func(s, a);
                return(KecaknoahNil.Instance.NoResume());
            };

            funcs[name] = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, wp));
        }
Exemplo n.º 26
0
 private void RegisterInstanceFunction()
 {
     add       = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceAdd));
     insert    = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceInsert));
     each      = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceEach));
     remove_at = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceRemoveAt));
     remove_by = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceRemoveBy));
     filter    = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFilter));
     map       = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceMap));
     reduce    = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceReduce));
 }
Exemplo n.º 27
0
        private KecaknoahReference find, each, filter, map, reduce;//, first, last;

        internal KecaknoahArray(int[] dim)
        {
            Type = TypeCode.Object;
            ExtraType = "Array";
            array = new List<KecaknoahReference>();
            length = KecaknoahReference.CreateRightReference(dim[0]);
            InitializeMembers();
            for (int i = 0; i < dim[0]; i++) array.Add(new KecaknoahReference { IsLeftValue = true, RawObject = KecaknoahNil.Instance });
            if (dim.Length == 1) return;
            for (int i = 0; i < array.Count; i++) array[i] = new KecaknoahReference { IsLeftValue = true, RawObject = new KecaknoahArray(dim.Skip(1).ToArray()) };
        }
Exemplo n.º 28
0
        private KecaknoahReference find, each, filter, map, reduce, copy;//, first, last;

        internal KecaknoahArray(int[] dim)
        {
            Type = TypeCode.Object;
            ExtraType = "Array";
            array = new List<KecaknoahReference>();
            length = KecaknoahReference.Right(dim[0]);
            InitializeMembers();
            for (int i = 0; i < dim[0]; i++) array.Add(KecaknoahReference.Left(KecaknoahNil.Instance));
            if (dim.Length == 1) return;
            for (int i = 0; i < array.Count; i++) array[i] = KecaknoahReference.Left(new KecaknoahArray(dim.Skip(1).ToArray()));
        }
Exemplo n.º 29
0
 /// <summary>
 /// 配列の新しいインスタンスを生成します。
 /// </summary>
 /// <param name="arr">生成する対象の<see cref="KecaknoahObject"/>のリスト</param>
 public KecaknoahArray(IEnumerable <KecaknoahObject> arr)
 {
     Type  = TypeCode.Object;
     array = new List <KecaknoahReference>();
     foreach (var i in arr)
     {
         array.Add(KecaknoahReference.Left(i));
     }
     length = KecaknoahReference.Right(arr.Count());
     InitializeMembers();
 }
Exemplo n.º 30
0
 private void RegisterInstanceFunction()
 {
     add       = KecaknoahReference.Right(this, InstanceAdd);
     add_range = KecaknoahReference.Right(this, InstanceAddRange);
     insert    = KecaknoahReference.Right(this, InstanceInsert);
     each      = KecaknoahReference.Right(this, InstanceEach);
     remove_at = KecaknoahReference.Right(this, InstanceRemoveAt);
     remove_by = KecaknoahReference.Right(this, InstanceRemoveBy);
     filter    = KecaknoahReference.Right(this, InstanceFilter);
     map       = KecaknoahReference.Right(this, InstanceMap);
     reduce    = KecaknoahReference.Right(this, InstanceReduce);
 }
Exemplo n.º 31
0
        /// <summary>
        /// 呼び出します。
        /// </summary>
        /// <param name="context"></param>
        /// <param name="args">引数</param>
        /// <returns>返り値</returns>
        protected internal override KecaknoahFunctionResult Call(KecaknoahContext context, KecaknoahObject[] args)
        {
            if (args != null)
            {
                CurrentFrame = new KecaknoahStackFrame(context, BaseMethod.Codes);
                CurrentFrame.Locals["self"] = KecaknoahReference.Right(Instance);
                CurrentFrame.Arguments      = args;
            }
            var r = CurrentFrame.Resume();

            return(new KecaknoahFunctionResult(CurrentFrame.ReturningObject, r));
        }
Exemplo n.º 32
0
 internal KecaknoahArray(List <KecaknoahObject> arr)
 {
     Type  = TypeCode.Object;
     array = new List <KecaknoahReference>();
     foreach (var i in arr)
     {
         array.Add(new KecaknoahReference {
             IsLeftValue = true, RawObject = i
         });
     }
     length = KecaknoahReference.CreateRightReference(arr.Count);
     InitializeMembers();
 }
Exemplo n.º 33
0
 /// <summary>
 /// 特定の<see cref="KecaknoahInteropClassInfo"/>を元にして、インスタンスを生成します。
 /// </summary>
 /// <param name="klass">クラス</param>
 public KecaknoahInstance(KecaknoahInteropClassInfo klass)
 {
     Class = klass;
     LocalFieldReferences = localReferences;
     InstanceMethodReferences = methodReferences;
     foreach (var i in klass.Locals) localReferences[i] = new KecaknoahReference() { IsLeftValue = true };
     foreach (var i in klass.methods)
         methodReferences[i.Name] = new KecaknoahReference()
         {
             IsLeftValue = true,
             RawObject = new KecaknoahInteropFunction(this, i.Body)
         };
 }
Exemplo n.º 34
0
        /// <summary>
        /// 指定された名前のメンバーへの参照を取得します。
        /// 「参照」というのは右辺値・左辺値どちらにもなりうる<see cref="KecaknoahReference"/>を差し、
        /// インスタンスごとに1つずつ(呼ばれる毎にnewしない)である必要があります。
        /// ここで返されるべき参照は
        /// ・インスタンスメソッド
        /// ・プロパティ
        /// などです。どちらもフィールドに<see cref="KecaknoahReference"/>のインスタンスを確保して
        /// switch分岐でそれらを返すことが推奨されます。
        /// </summary>
        /// <param name="name">メンバー名</param>
        /// <returns></returns>
        protected internal override KecaknoahReference GetMemberReference(string name)
        {
            switch (name)
            {
            case nameof(each): return(each);

            case nameof(remove): return(remove);

            case nameof(has_key): return(has_key);

            case "length": return(KecaknoahReference.Right(dict.Count));
            }
            return(base.GetMemberReference(name));
        }
Exemplo n.º 35
0
        /// <summary>
        /// 新しいインスタンスを生成します。
        /// </summary>
        public KecaknoahString()
        {
            Type      = TypeCode.String;
            ExtraType = "String";

            split     = KecaknoahReference.Right(this, InstanceSplit);
            replace   = KecaknoahReference.Right(this, InstanceReplace);
            substring = KecaknoahReference.Right(this, InstanceSubstring);
            to_upper  = KecaknoahReference.Right(this, InstanceToUpper);
            to_lower  = KecaknoahReference.Right(this, InstanceToLower);
            starts    = KecaknoahReference.Right(this, InstanceStartsWith);
            ends      = KecaknoahReference.Right(this, InstanceEndsWith);
            pad_left  = KecaknoahReference.Right(this, InstancePadLeft);
            pad_right = KecaknoahReference.Right(this, InstancePadRight);
        }
Exemplo n.º 36
0
        /// <summary>
        /// 特定の名前を持つメンバーに対してアクセスを試み、参照を取得します。
        /// </summary>
        /// <param name="name">メンバー名</param>
        /// <returns>アクセスできる場合は対象のオブジェクト</returns>
        protected internal virtual KecaknoahReference GetMemberReference(string name)
        {
            switch (name)
            {
            case "to_str":
                return(InstanceToString(this));

            case "hash":
                return(InstanceHash(this));

            case "type":
                return(KecaknoahReference.Right(ExtraType));

            default:
                return(KecaknoahNil.Reference);
            }
        }
Exemplo n.º 37
0
 /// <summary>
 /// 特定の<see cref="KecaknoahScriptClassInfo"/>を元にして、インスタンスを生成します。
 /// コンストラクタがあった場合、呼び出します。
 /// </summary>
 /// <param name="klass">クラス</param>
 /// <param name="ctx">コンテキスト</param>
 /// <param name="ctorArgs">コンストラクタ引数</param>
 public KecaknoahInstance(KecaknoahScriptClassInfo klass, KecaknoahContext ctx, KecaknoahObject[] ctorArgs)
 {
     Class = klass;
     LocalFieldReferences = localReferences;
     InstanceMethodReferences = methodReferences;
     foreach (var i in klass.Locals) localReferences[i] = new KecaknoahReference() { IsLeftValue = true };
     foreach (var i in klass.methods)
         methodReferences[i.Name] = new KecaknoahReference()
         {
             IsLeftValue = true,
             RawObject = new KecaknoahScriptFunction(this, i)
         };
     if (klass.classMethods.Any(p => p.Name == "new"))
     {
         var ctor = klass.classMethods.First(p => p.Name == "new");
         new KecaknoahScriptFunction(this, ctor).Call(ctx, ctorArgs);
     }
 }
Exemplo n.º 38
0
#pragma warning disable 1591
        protected internal override KecaknoahReference GetMemberReference(string name)
        {
            KecaknoahReference result;

            if (PropertyReferences.TryGetValue(name, out result))
            {
                return(result);
            }
            if (FunctionReferences.TryGetValue(name, out result))
            {
                return(result);
            }
            result = new KecaknoahReference {
                IsLeftValue = true
            };
            props[name] = result;
            return(result);
        }
Exemplo n.º 39
0
        private KecaknoahReference find, each, filter, map, reduce;//, first, last;

        internal KecaknoahArray(int[] dim)
        {
            Type      = TypeCode.Object;
            ExtraType = "Array";
            array     = new List <KecaknoahReference>();
            length    = KecaknoahReference.Right(dim[0]);
            InitializeMembers();
            for (int i = 0; i < dim[0]; i++)
            {
                array.Add(KecaknoahReference.Left(KecaknoahNil.Instance));
            }
            if (dim.Length == 1)
            {
                return;
            }
            for (int i = 0; i < array.Count; i++)
            {
                array[i] = KecaknoahReference.Left(new KecaknoahArray(dim.Skip(1).ToArray()));
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// メンバーの参照を取得します。
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected internal override KecaknoahReference GetMemberReference(string name)
        {
            if (LocalFieldReferences.ContainsKey(name))
            {
                return(LocalFieldReferences[name]);
            }
            if (InstanceMethodReferences.ContainsKey(name))
            {
                return(InstanceMethodReferences[name]);
            }
            KecaknoahReference result;

            if ((result = base.GetMemberReference(name)) == KecaknoahNil.Reference)
            {
                result = localReferences[name] = new KecaknoahReference {
                    IsLeftValue = true
                };
            }
            return(result);
        }
Exemplo n.º 41
0
 /// <summary>
 /// 特定の<see cref="KecaknoahInteropClassInfo"/>を元にして、インスタンスを生成します。
 /// </summary>
 /// <param name="klass">クラス</param>
 public KecaknoahInstance(KecaknoahInteropClassInfo klass)
 {
     Class = klass;
     LocalFieldReferences     = localReferences;
     InstanceMethodReferences = methodReferences;
     foreach (var i in klass.Locals)
     {
         localReferences[i] = new KecaknoahReference()
         {
             IsLeftValue = true
         }
     }
     ;
     foreach (var i in klass.methods)
     {
         methodReferences[i.Name] = new KecaknoahReference()
         {
             IsLeftValue = true,
             RawObject   = new KecaknoahInteropFunction(this, i.Body)
         }
     }
     ;
 }
Exemplo n.º 42
0
        private void RegisterInstanceMembers()
        {
            i_get_int = KecaknoahReference.Right(this, InstanceGetInteger);
            i_get_float = KecaknoahReference.Right(this, InstanceGetFloat);

        }
Exemplo n.º 43
0
 private void RegisterInstanceMembers()
 {
     i_add = KecaknoahReference.Right(this, InstanceAdd);
     i_add_days = KecaknoahReference.Right(this, InstanceAddDays);
     i_add_hours = KecaknoahReference.Right(this, InstanceAddHours);
     i_add_minutes = KecaknoahReference.Right(this, InstanceAddMinutes);
     i_add_months = KecaknoahReference.Right(this, InstanceAddMonths);
     i_add_seconds = KecaknoahReference.Right(this, InstanceAddSeconds);
     i_add_ticks = KecaknoahReference.Right(this, InstanceAddTicks);
     i_add_years = KecaknoahReference.Right(this, InstanceAddYears);
     i_sub = KecaknoahReference.Right(this, InstanceSub);
     i_to_local = KecaknoahReference.Right(this, InstanceToLocal);
 }
Exemplo n.º 44
0
 private void RegisterInstanceMembers()
 {
     i_add = KecaknoahReference.Right(this, InstanceAdd);
     i_sub = KecaknoahReference.Right(this, InstanceSub);
 }
Exemplo n.º 45
0
#pragma warning disable 1591
        protected internal override KecaknoahReference GetMemberReference(string name)
        {
            KecaknoahReference result;
            if (PropertyReferences.TryGetValue(name, out result)) return result;
            if (FunctionReferences.TryGetValue(name, out result)) return result;
            result = new KecaknoahReference { IsLeftValue = true };
            props[name] = result;
            return result;
        }
Exemplo n.º 46
0
        private void RegisterInstanceMembers()
        {
            i_match = KecaknoahReference.Right(this, InstanceMatch);
            i_split = KecaknoahReference.Right(this, InstanceSplit);

        }
Exemplo n.º 47
0
 /// <summary>
 /// インデクサーの参照を得ます。
 /// <see cref="GetMemberReference(string)"/>と<see cref="KecaknoahObject.Call(KecaknoahContext, KecaknoahObject[])"/>の
 /// 中間のような存在です。
 /// </summary>
 /// <param name="indices">インデックス</param>
 /// <returns>返す参照</returns>
 protected internal override KecaknoahReference GetIndexerReference(KecaknoahObject[] indices)
 {
     if (!dict.ContainsKey(indices[0]))
     {
         dict[indices[0]] = new KecaknoahReference { IsLeftValue = true };
     }
     return dict[indices[0]];
 }
Exemplo n.º 48
0
 private void RegisterInstanceFunction()
 {
     each = KecaknoahReference.Right(this, InstanceEach);
     remove = KecaknoahReference.Right(this, InstanceRemove);
     has_key = KecaknoahReference.Right(this, InstanceHasKey);
 }
Exemplo n.º 49
0
 /// <summary>
 /// メソッドを登録します。
 /// </summary>
 /// <param name="name">メソッド名</param>
 /// <param name="func">登録するメソッドのデリゲート</param>
 public void AddFunction(string name, KecaknoahInteropDelegate func)
 {
     funcs[name] = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, func));
 }
Exemplo n.º 50
0
 internal KecaknoahRegexCapture(Capture c)
 {
     cap = c;
     length = KecaknoahReference.Right(cap.Length);
     index = KecaknoahReference.Right(cap.Index);
     value = KecaknoahReference.Right(cap.Value);
 }
Exemplo n.º 51
0
        /// <summary>
        /// メソッドを登録します。
        /// </summary>
        /// <param name="name">メソッド名</param>
        /// <param name="func">
        /// 登録するメソッドのデリゲート。
        /// インスタンスと引数が渡されます。
        /// </param>
        public void AddFunction(string name, Func <KecaknoahObject, KecaknoahObject[], string> func)
        {
            KecaknoahInteropDelegate wp = (c, s, a) => func(s, a).AsKecaknoahString().NoResume();

            funcs[name] = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, wp));
        }
Exemplo n.º 52
0
 /// <summary>
 /// メンバーの参照を取得します。
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 protected internal override KecaknoahReference GetMemberReference(string name)
 {
     if (LocalFieldReferences.ContainsKey(name)) return LocalFieldReferences[name];
     if (InstanceMethodReferences.ContainsKey(name)) return InstanceMethodReferences[name];
     KecaknoahReference result;
     if ((result = base.GetMemberReference(name)) == KecaknoahNil.Reference)
     {
         result = localReferences[name] = new KecaknoahReference { IsLeftValue = true };
     }
     return result;
 }
Exemplo n.º 53
0
 internal KecaknoahRegexGroup(Group g)
 {
     gr = g;
     length = KecaknoahReference.Right(gr.Length);
     index = KecaknoahReference.Right(gr.Index);
     value = KecaknoahReference.Right(gr.Value);
 }
Exemplo n.º 54
0
 private void RegisterInstanceFunction()
 {
     add = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceAdd));
     insert = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceInsert));
     each = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceEach));
     remove_at = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceRemoveAt));
     remove_by = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceRemoveBy));
     filter = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceFilter));
     map = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceMap));
     reduce = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceReduce));
 }
Exemplo n.º 55
0
 internal KecaknoahDynamicLibraryObject(object self)
 {
     ExtraType = ClassName;
     type = self?.GetType();
     name = KecaknoahReference.Right(type?.Name ?? "");
     rawobj = self;
 }
Exemplo n.º 56
0
 private void RegisterInstanceFunction()
 {
     add = KecaknoahReference.Right(this, InstanceAdd);
     add_range = KecaknoahReference.Right(this, InstanceAddRange);
     clear = KecaknoahReference.Right(this, InstanceClear);
     insert = KecaknoahReference.Right(this, InstanceInsert);
     each = KecaknoahReference.Right(this, InstanceEach);
     remove_at = KecaknoahReference.Right(this, InstanceRemoveAt);
     remove_by = KecaknoahReference.Right(this, InstanceRemoveBy);
     filter = KecaknoahReference.Right(this, InstanceFilter);
     map = KecaknoahReference.Right(this, InstanceMap);
     reduce = KecaknoahReference.Right(this, InstanceReduce);
     any = KecaknoahReference.Right(this, list.Select(p => p.RawObject).GenerateAnyFunction());
     all = KecaknoahReference.Right(this, list.Select(p => p.RawObject).GenerateAllFunction());
 }
Exemplo n.º 57
0
        internal KecaknoahExtensionClass(KecaknoahExternalClassInfo kec)
        {
            ExtraType = ClassName;
            exclass = kec;
            cobj = new KecaknoahInteropClassObject(exclass.Information);
            cobjRef = KecaknoahReference.Right(cobj);

            isStatic = exclass.IsStaticClass;
            if (!isStatic)
            {
                i_create = KecaknoahReference.Right(this, InstanceCreate);
                ctor = cobj.Class.classMethods.FirstOrDefault(p => p.Name == "new");
                if (ctor == null) throw new CompositionException("staticクラスでないにもかかわらずコンストラクタがありません。");
            }
        }
Exemplo n.º 58
0
 internal KecaknoahDynamicLibraryField(object self, FieldInfo fi)
 {
     ExtraType = ClassName;
     instance = self;
     info = fi;
     getter = KecaknoahReference.Right(new KecaknoahInteropFunction(this, InstanceGet));
     setter = KecaknoahReference.Right(new KecaknoahInteropFunction(this, InstanceSet));
 }
Exemplo n.º 59
0
 private void RegisterInstanceFunction()
 {
     each = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceEach));
     remove = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceRemove));
     has_key = KecaknoahReference.CreateRightReference(new KecaknoahInteropFunction(this, InstanceHasKey));
 }
Exemplo n.º 60
0
 /// <summary>
 /// 新しいインスタンスを生成します。
 /// </summary>
 public KecaknoahString()
 {
     Type = TypeCode.String;
     Replace = KecaknoahReference.CreateRightReference(this, InstanceReplace);
     Substring = KecaknoahReference.CreateRightReference(this, InstanceSubstring);
 }