txlyre 3 天之前
父节点
当前提交
bde76b552f
共有 3 个文件被更改,包括 272 次插入234 次删除
  1. 3 1
      qirt.c
  2. 256 226
      qistd.c
  3. 13 7
      std.qi

+ 3 - 1
qirt.c

@@ -1352,10 +1352,12 @@ void qi_unset_trap(qi_state_t *state, qi_trap_t *trap) {
 
 void qi_throw(qi_state_t *state, qi_value_t *value) {
   if (qi_list_empty(state->traps)) {
+    char *s = qi_repr(state, value, false);
+
     while (qi_old_scope(state))
       ;
 
-    qi_fatal(state, "uncaught exception: %s", qi_repr(state, value, false));
+    qi_fatal(state, "uncaught exception: %s", s);
   }
 
   qi_trap_t *trap = qi_list_last(state->traps);

文件差异内容过多而无法显示
+ 256 - 226
qistd.c


+ 13 - 7
std.qi

@@ -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
+}

部分文件因为文件数量过多而无法显示