BindMethod() public method

public BindMethod ( int symbol, Method method ) : void
symbol int
method Method
return void
コード例 #1
0
ファイル: WrenVM.cs プロジェクト: minirop/Wren.NET
        // Defines [methodValue] as a method on [classObj].
        private static Value BindMethod(MethodType methodType, int symbol, ObjClass classObj, Value methodContainer)
        {
            ObjFn methodFn = methodContainer.Obj as ObjFn ?? ((ObjClosure)methodContainer.Obj).Function;

            // Methods are always bound against the class, and not the metaclass, even
            // for static methods, because static methods don't have instance fields
            // anyway.
            Compiler.BindMethodCode(classObj, methodFn);

            Method method = new Method { mType = MethodType.Block, obj = methodContainer.Obj };

            if (methodType == MethodType.Static)
                classObj = classObj.ClassObj;

            //classObj.Methods[symbol] = method;
            classObj.BindMethod(symbol, method);
            return new Value (ValueType.Null);
        }
コード例 #2
0
ファイル: WrenVM.cs プロジェクト: robotii/Wren.NET
        public void Primitive(ObjClass objClass, string s, Primitive func)
        {
            if (!MethodNames.Contains(s))
            {
                MethodNames.Add(s);
            }
            int symbol = MethodNames.IndexOf(s);

            objClass.BindMethod(symbol, new Method { Primitive = func, MType = MethodType.Primitive });
        }
コード例 #3
0
ファイル: WrenVM.cs プロジェクト: robotii/Wren.NET
        // Defines [methodValue] as a method on [classObj].
        private static bool BindMethod(bool isStatic, int symbol, ObjClass classObj, Obj methodContainer)
        {
            // If we are binding a foreign method, just return, as this will be handled later
            if (methodContainer is ObjString)
                return true;

            ObjFn methodFn = methodContainer as ObjFn ?? ((ObjClosure)methodContainer).Function;

            Method method = new Method { MType = MethodType.Block, Obj = methodContainer };

            if (isStatic)
                classObj = classObj.ClassObj;

            // Methods are always bound against the class, and not the metaclass, even
            // for static methods, because static methods don't have instance fields
            // anyway.
            Compiler.BindMethodCode(classObj, methodFn);

            classObj.BindMethod(symbol, method);
            return true;
        }
コード例 #4
0
ファイル: WrenVM.cs プロジェクト: robotii/Wren.NET
        public void Call(ObjClass objClass, string s)
        {
            if (!MethodNames.Contains(s))
            {
                MethodNames.Add(s);
            }
            int symbol = MethodNames.IndexOf(s);

            objClass.BindMethod(symbol, new Method { MType = MethodType.Call });
        }