--- /dev/null
+#! [contains] forks must be stored in a value
+fork { <<< 1 >>>; };
--- /dev/null
+#! [contains] can't use non global fptr of other class
+class C {
+ typedef void t_ptr() {}
+}
+class D {
+ typedef void t_ptr() {}
+ C->t_ptr ptr;
+}
--- /dev/null
+#! [contains] can't use non public typedef at global scope
+class C {
+ typedef void t_ptr();
+}
+C->t_ptr ptr;
--- /dev/null
+#! [contains] non-static member 'i' used from static function
+class C {
+ int i;
+ fun static void test() { <<< i >>>; }
+}
--- /dev/null
+#! [contains] StackOverflow
+fun void test() { test(); }
+test();
--- /dev/null
+#! [contains] pre-defined types
+typedef void t_ptr<~A~>();
+
+<~int~>t_ptr iptr;
+
+fun void test<~A~>() {
+ <<< __func__ >>>;
+}
+
+test @=> iptr;
+#!<<< iptr<~int~>() >>>;
+<<< iptr() >>>;
+<<< iptr<~int~>() >>>;
+<<< iptr<~float~>() >>>;
+<<< iptr<~Object~>() >>>;
--- /dev/null
+#! [contains] pre-defined types
+typedef void t_ptr<~A~>();
+typedef <~int~>t_ptr B;
+
+fun void test<~A~>() {
+ <<< __func__ >>>;
+}
+
+test @=> B b;
+#!<<< iptr<~int~>() >>>;
+<<< b() >>>;
+<<< b<~int~>() >>>;
--- /dev/null
+#include "gwion_util.h"
+#include "gwion_ast.h"
+#include "oo.h"
+#include "vm.h"
+#include "env.h"
+#include "type.h"
+#include "object.h"
+#include "instr.h"
+#include "gwion.h"
+#include "operator.h"
+#include "import.h"
+
+static MFUN(test_func) { puts("test"); }
+GWION_IMPORT(typedef_test) {
+ Type t_func_typedef;
+ CHECK_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL)))
+ CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
+ CHECK_OB(gwi_fptr_end(gwi, 0))
+
+ CHECK_BB(gwi_class_ini(gwi, t_func_typedef, NULL, NULL))
+ CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
+ CHECK_OB(gwi_fptr_end(gwi, ae_flag_static))
+ CHECK_BB(gwi_func_ini(gwi, "void", "test_func", test_func))
+ CHECK_BB(gwi_func_end(gwi, ae_flag_static))
+ CHECK_BB(gwi_item_ini(gwi, "PtrType", "ptr"))
+ CHECK_BB(gwi_item_end(gwi, ae_flag_static, NULL))
+ CHECK_BB(gwi_class_end(gwi))
+ return GW_OK;
+}
--- /dev/null
+fun void test(){ <<< "test" >>>; }
+PtrType ptr;
+test();
+test @=> ptr;
+ptr();
+
+
+FuncTypedef.test_func();
+<<< FuncTypedef.test_func @=> FuncTypedef.ptr >>>;
+<FuncTypedef.PtrType> _ptr;
+<<< FuncTypedef.ptr >>>;
+FuncTypedef.ptr();
+
#include "operator.h"
#include "import.h"
-static MFUN(test_func) { puts("test"); }
GWION_IMPORT(typedef_test) {
- Type t_func_typedef;
- CHECK_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT , NULL)))
- CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
- CHECK_OB(gwi_fptr_end(gwi, 0))
-
- CHECK_BB(gwi_class_ini(gwi, t_func_typedef, NULL, NULL))
- CHECK_BB(gwi_fptr_ini(gwi, "void", "PtrType"))
- CHECK_OB(gwi_fptr_end(gwi, ae_flag_static))
- CHECK_BB(gwi_func_ini(gwi, "void", "test_func", test_func))
- CHECK_BB(gwi_func_end(gwi, ae_flag_static))
- CHECK_BB(gwi_item_ini(gwi, "PtrType", "ptr"))
- CHECK_BB(gwi_item_end(gwi, ae_flag_static, NULL))
- CHECK_BB(gwi_class_end(gwi))
+ GWI_OB(gwi_typedef_ini(gwi, "int", "Typedef"))
+ GWI_OB(gwi_typedef_end(gwi, ae_flag_none))
return GW_OK;
}
-fun void test(){ <<< "test" >>>; }
-PtrType ptr;
-test();
-test @=> ptr;
-ptr();
-
-
-FuncTypedef.test_func();
-<<< FuncTypedef.test_func @=> FuncTypedef.ptr >>>;
-<FuncTypedef.PtrType> _ptr;
-<<< FuncTypedef.ptr >>>;
-FuncTypedef.ptr();
-
+Typedef t;
+#!fun int test(int i) { <<< i >>>; }
+#!test @=> t;
+<<< t >>>;
#!/bin/bash
-# [test] #31
+# [test] #32
n=0
[ "$1" ] && n="$1"
--- /dev/null
+typedef void t_ptr(int i);
+typedef t_ptr A;
+A a;
+<<<a>>>;
+
+fun void test(int i) { <<< __func__ , " ", i>>>; }
+test @=> a;
+a(1);
--- /dev/null
+class C {
+typedef void t_ptr();
+typedef t_ptr A;
+A a;
+<<<a>>>;
+
+fun void test() { <<< __func__ >>>; }
+test @=> a;
+a();
+a();
+a();
+}
+
+C c;
--- /dev/null
+typedef void t_ptr<~A~>();
+
+<~int~>t_ptr iptr;
+<~float~>t_ptr fptr;
+
+fun void test<~A~>() {
+ <<< __func__ >>>;
+}
+
+test @=> iptr;
+test @=> fptr;
+
+<<< iptr() >>>;
+<<< iptr() >>>;
+<<< fptr() >>>;
+<<< fptr() >>>;
--- /dev/null
+typedef void t_ptr<~A~>();
+fun void test<~A~>() {
+ <<< __func__ >>>;
+}
+
+typedef <~int~>t_ptr B;
+B b;
+<<< b >>>;
+test @=> b;
+<<< b >>>;
+<<< b() >>>;
+<<< b() >>>;
+
+
+typedef <~float~>t_ptr C;
+C c;
+<<< c >>>;
+test @=> c;
+<<< c >>>;
+<<< c() >>>;
+<<< c() >>>;
+
+<<< b() >>>;
+<<< c() >>>;
--- /dev/null
+class C {
+ typedef void t_ptr<~A~>();
+
+ <~int~>t_ptr iptr;
+
+ fun void test<~A~>() {
+ <<< this, " ", __func__ >>>;
+ }
+
+ test @=> iptr;
+ <<< iptr() >>>;
+#! <<< iptr() >>>;
+}
+<<<C c>>>;
+ <<< c.iptr() >>>;
+#! <<< c.iptr() >>>;