private static SqDotNet.Object GenerateInstanceRef(Squirrel vm, SqClass sqClass) { sqClass.PushSelf(); vm.CreateInstance(-1); vm.GetStackObj(-1, out var obj); return(obj); }
public bool IsInstanceOf(SqClass sqClass) { PushSelf(); sqClass.PushSelf(); var isInstance = VM.InstanceOf(); VM.Pop(2); return(isInstance); }
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); }
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); })); }
public SqInstance(SqClass sqClass) : this(GenerateInstanceRef(ScriptHandler.Squirrel, sqClass)) { VM.Pop(2); }