|
@@ -433,22 +433,19 @@ func is_object(o): return has_meta_table(o)
|
|
|
func __class_wrapper(n, p, t, mt, st): return Object(st + {
|
|
|
t: t,
|
|
|
mt: mt,
|
|
|
- super: [],
|
|
|
+ super: p,
|
|
|
__type: func (this) use (n): return n,
|
|
|
__str: func (this) use (n): return "<class " + n + ">",
|
|
|
- __call: func (this, pargs) use (p) {
|
|
|
+ __call: func (this, pargs) use (n, p) {
|
|
|
var t = {}
|
|
|
- var mt = {}
|
|
|
+ var mt = { __type: func (this) use (n): n }
|
|
|
for var other of p {
|
|
|
t += other.t
|
|
|
mt += other.mt
|
|
|
- list_push(this.super, other)
|
|
|
}
|
|
|
- if len(this.super) == 1
|
|
|
- this.super = this.super[0]
|
|
|
t += this.t
|
|
|
mt += this.mt
|
|
|
- t.super = this.super
|
|
|
+ mt.super = this.super
|
|
|
obj = set_meta_table(t, mt)
|
|
|
if "constructor" in mt
|
|
|
func_call(mt.constructor, [obj] + pargs)
|
|
@@ -528,3 +525,12 @@ set_pseudomethod("file.__leave", func (f): fclose(f))
|
|
|
func assert(cond, msg="assertion failed")
|
|
|
if !cond
|
|
|
throw msg
|
|
|
+class Error {
|
|
|
+ msg = nil
|
|
|
+
|
|
|
+ constructor (this, msg) {
|
|
|
+ this.msg = msg
|
|
|
+ }
|
|
|
+
|
|
|
+ __str (this): type(this) + ": " + this.msg
|
|
|
+}
|