Пример #1
0
 private static SqDotNet.Object GenerateInstanceRef(Squirrel vm, SqClass sqClass)
 {
     sqClass.PushSelf();
     vm.CreateInstance(-1);
     vm.GetStackObj(-1, out var obj);
     return(obj);
 }
Пример #2
0
        public bool IsInstanceOf(SqClass sqClass)
        {
            PushSelf();
            sqClass.PushSelf();
            var isInstance = VM.InstanceOf();

            VM.Pop(2);
            return(isInstance);
        }
Пример #3
0
        private static SqDotNet.Object GenerateClassRef(Squirrel vm, SqClass baseClass)
        {
            var hasBase = !(baseClass is null);

            if (hasBase)
            {
                baseClass.PushSelf();
            }
            vm.NewClass(hasBase);
            vm.GetStackObj(-1, out var obj);
            return(obj);
        }
Пример #4
0
        public SqClass(string className, SqClass baseClass = null) : this(GenerateClassRef(ScriptHandler.Squirrel, baseClass))
        {
            VM.Pop(baseClass is null ? 1 : 2);

            SetDelegateMethod("_typeof", ScriptHandler.MakeFunction((_, __) => { VM.PushString(className, -1); return(1); }));
        }
Пример #5
0
 public SqInstance(SqClass sqClass) : this(GenerateInstanceRef(ScriptHandler.Squirrel, sqClass))
 {
     VM.Pop(2);
 }