]> Nishi Git Mirror - gwion.git/commitdiff
:art: Check instance array
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sat, 29 Dec 2018 20:08:08 +0000 (21:08 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 30 Dec 2018 16:40:29 +0000 (17:40 +0100)
32 files changed:
ast
examples/in_class_class.gw
examples/template.gw
examples/template_guess.gw
examples/template_vararg.gw
include/gwion.h
src/compile.c
src/gwion.c
src/parse/scan1.c
tests/bug/Tester.gw
tests/bug/template_no_guess.gw
tests/error/new_empty_array.gw
tests/error/non_function_template.gw
tests/error/template_class_no_type.gw
tests/error/template_enough.gw
tests/error/template_n_mismatch.gw
tests/error/template_no_match.gw
tests/error/template_non_member.gw
tests/error/template_unknown.gw
tests/error/type_not_template.gw
tests/test_plugins/class_template.gw
tests/test_plugins/extend_pair.gw
tests/test_plugins/map2.gw
tests/tree/auto_ptr.gw
tests/tree/class_template.gw
tests/tree/map.gw
tests/tree/pair.gw
tests/tree/static_template.gw
tests/tree/template_class_ref.gw
tests/tree/template_ternary.gw
tests/tree/template_typedef.gw
util

diff --git a/ast b/ast
index 90919a17d261acf6b31d0b33981371b211f0cb2c..66d993ff6c549baffd5b863a7f9761d8f52b63a5 160000 (submodule)
--- a/ast
+++ b/ast
@@ -1 +1 @@
-Subproject commit 90919a17d261acf6b31d0b33981371b211f0cb2c
+Subproject commit 66d993ff6c549baffd5b863a7f9761d8f52b63a5
index e0ec4e4a27507a8e54699dcad99f81182ab793a8..b0ab876890a979099add51138446ee389bb9c25c 100644 (file)
@@ -1,6 +1,5 @@
-class C
-{
-       template<a>
+class C {
+       template<~a~>
        function void test(a var){ <<<var>>>; }
        class D { int i;}
 }
index 401d0c5d9310e82d3e212af8e5b2dc132265fc32..23f8647e6ca450ec89c23301cc232066accb03ba 100644 (file)
@@ -1,13 +1,13 @@
-template <a>
+template <~a~>
 function void test (a var){ <<< var>>>; }
-template <a, b>
+template <~a, b~>
 function void test (a var, b var2){ <<< var>>>; }
 //function void test (){ }
 
-test<int>(1);
+test<~int~>(1);
 //test<float>(1.4);
 //test<int>(3, 1.4);
 //test<float>(3);
 //test(3, 1.4);
-test<float, float>(3, 1.4);
+test<~float, float~>(3, 1.4);
 //test<float, float, int>(3, 1.4);
index dcb87d0fc4d2a8a59f25ab6738419d5ae16767a4..85d940843b05eb54c1f6ed4ca9150c2cea3d0600 100644 (file)
@@ -1,4 +1,4 @@
-template <A, B>
+template <~A, B~>
 function void test(A a, B b){<<<a, ", ", b>>>;}
 test(1, 2.1);
 test(1.1, 2.1);
index 79cddc89ad9734b472c225244effcb8e8061e63c..d9914d32e486e97b70ac5a5da8cb61ff88f68af6 100644 (file)
@@ -1,8 +1,8 @@
-template <a>
+template <~a~>
 fun void test(...) {
   vararg.start;
   <<<vararg.i>>>;
   vararg.end;
 }
-test<int>(1, 2);
-test<float>(1, 2, 3);
+test<~int~>(1, 2);
+test<~float~>(1, 2, 3);
index 68110c7d335003c971f8fa8e2ab799bdcdc6f289..6f68675cd2524f0e60183f0ed91cfb7a01d899c8 100644 (file)
@@ -6,7 +6,6 @@ struct Gwion_ {
 // mem
 // rnd
 // dl
-  Scanner *scan;
   Env      env;
   Emitter  emit;
   VM*      vm;
index 63653e436efe410c88f6d9a967068e502eaa6426..14f7f5bd458e1830fcef37b65088c2804913e9c3 100644 (file)
@@ -60,7 +60,7 @@ static m_bool compiler_open(struct Compiler* c) {
 
 static m_bool check(struct Gwion_* gwion, struct Compiler* c) {
   CHECK_BB(compiler_open(c))
-  CHECK_OB((c->ast = parse(gwion->scan, c->name, c->file)))
+  CHECK_OB((c->ast = parse(c->name, c->file)))
   gwion->env->name = c->name;
   return type_engine_check_prog(gwion->env, c->ast);
 }
index 5e801938e19b44a6f165db684db3a2abcc85437c..d8ab56676cf25cf909c122c9e984cffd99ed8b53 100644 (file)
@@ -11,7 +11,6 @@ ANN void gwion_init(const Gwion gwion) {
   gwion->vm = new_vm();
   gwion->emit = new_emitter();
   gwion->env = new_env();
-  gwion->scan = new_scanner(127); // !!! magic number
   gwion->emit->env = gwion->env;
   gwion->vm->gwion = gwion;
   gwion->env->gwion = gwion;
@@ -21,6 +20,5 @@ ANN void gwion_release(const Gwion gwion) {
   free_env(gwion->env);
   free_emitter(gwion->emit);
   free_vm(gwion->vm);
-  free_scanner(gwion->scan);
   free_symbols();
 }
index b10a80279799ae3de3b4c9be9a6d93f772b058ba..9c8181047a9580365bb9dbd7ca34903be7b2bc70 100644 (file)
@@ -312,12 +312,8 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
 DECL_SECTION_FUNC(scan1)
 
 ANN static m_bool scan1_class_parent(const Env env, const Class_Def class_def) {
-  if(class_def->ext->array) {
-    if(class_def->ext->array->exp)
-      CHECK_BB(scan1_exp(env, class_def->ext->array->exp))
-    else
-      ERR_B(class_def->ext->xid->pos, "can't use empty []'s in class extend")
-  }
+  if(class_def->ext->array)
+    CHECK_BB(scan1_exp(env, class_def->ext->array->exp))
   const Type parent = class_def->type->parent = known_type(env, class_def->ext);
   CHECK_OB(parent)
   if(isa(class_def->type->parent, t_object) < 0)
index baa73dcf447b4a2786c2474fbd3ec36e9414e8af..ee55739a8b09a143eacd5cf9f2cf37ae6b513363 100644 (file)
@@ -1,8 +1,8 @@
 class Tester
 {
-       template<A>
+       template<~A~>
        function int assert_equal(string description, A a, A b){ if(a == b) return 0; return 1; }
-       template<A>
+       template<~A~>
        function int assert_not_equal(string description, A a, A b){ if(a != b) return 0; return 1; }
 }
 
index aaa3b36fc3a7336151a3db62603c2ff9eadbb207..03ef8747588ead6b4bff2db88262b78e48e6e3b4 100644 (file)
@@ -1,4 +1,4 @@
-//template <a>
+//template <~a~>
 function void test(){}
 //function void test(int i[]){<<<i>>>;}
 //function void test(Object o){}
index 57c8aae888bf605f5262fb7659628c838967ebfb..1655e517ce398307c15317aab5f4deebcf7b3895 100644 (file)
@@ -1,2 +1,2 @@
-// [contains] can't use empty
+// [contains] instantiate with empty
 new Object[];
index 795346a0e06ae99c685afeb4dd4cd633877f7f45..42d955025b65dc823effe8ade771f006ed1b6e13 100644 (file)
@@ -1,3 +1,3 @@
 // [contains] template call of non-function value
 int test;
-test<int>();
+test<~int~>();
index 27e0162170bf00c5f06ccd48017c66f3abd1eb1f..d46f774505faca00fcb37521c9a3724cdad299d0 100644 (file)
@@ -1,5 +1,5 @@
 // [contains] you must provide template types
-template<A>
+template<~A~>
 class C {
   A a;
 }
index 1acbf217a231df359bd25f8b0007f5053969f553..2fd7cc12aa313e9aea743818cc1a8c37b5c40abf 100644 (file)
@@ -1,4 +1,4 @@
 // [contains] 
- template<a, b>
+ template<~a, b~>
 function void test(){}
 test();
index 97dc0cf1bbc1773416d7365e16ece2f978f190c1..44a74172941428d5a788930372cfe2d51802aaa3 100644 (file)
@@ -1,8 +1,8 @@
 // [contains] arguments do not match for template call
-template <i>
+template <~i~>
 function void test(){ <<<"func">>>;}
-template <i>
+template <~i~>
 function void test(int i){<<<"other func">>>;}
 
-test<int, float, int>();
-//test<int>();
+test<~int, float, int~>();
+//test<~int~>();
index e95d70c0f6a792fccdddf630b747a1869520c17b..02ed2e53493e1f6562d80dbb89acb45be3fcbed8 100644 (file)
@@ -1,12 +1,11 @@
 // [contains] arguments do not match for template call
-class C
-{
-       template <a>
+class C {
+       template <~a~>
        function void test(float f) {}
-       template <a>
+       template <~a~>
        function void test() {}
 }
 C c;
-//c.test<int>();
-c.test<int>(2.3);
-c.test<int>(2.3, 2.3);
+//c.test<~int~>();
+c.test<~int~>(2.3);
+c.test<~int~>(2.3, 2.3);
index f25211d43a1e05dfa19038cf34d45db6517fc9cc..1d287d6b2da7bbb8479ada0ff89ede2ed2a1ed3d 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] 
- Math.rand<int>();
+Math.rand<~int~>();
index b380cc811b46446f0f1af005be9902cd9191f061..85b4eaf0d546c80e3945dc134aed97e1a1b07e69 100644 (file)
@@ -1,5 +1,5 @@
 // [contains] unknown type
- template<my_type>
+ template<~my_type~>
 function void my_function() { <<<"test">>>; }
 
-my_function<unknown_type>();
+my_function<~unknown_type~>();
index b9f747d87d17e1b5d06a3bafae6a2f93506e04b2..4436e0d407e3ac3c0be31940c527b32d6688c327 100644 (file)
@@ -1,2 +1,2 @@
 // [contains] is not template
-<int>Object o;
+<~int~>Object o;
index f72be7aa51e6c2499ad0b316ee84ae6c2430af79..245aca5819373a184aed774337ddd2147c15f41a 100644 (file)
@@ -1,13 +1,13 @@
 //class child {}
-//template<A, B>
+//template<~A, B~>
 //class C{ A key; B value; }
-//<int, int>C c1;
+//<~int, int~>C c1;
 //<float, float>C c2;
 //<<<c1>>>;
 //<<<c2>>>;
 //<<<c2.value>>>;
 
-<int, int>ClassTemplate ct;
+<~int, int~>ClassTemplate ct;
 <<<ct.key>>>;
 //<float, float>ClassTemplate ct2;
 //<<<ct2.key>>>;
index 48354420ad4f28387bdd993bf57085b2bed30b86..f32763dc89ffbbacb29fab75f77e29fbdc76397b 100644 (file)
@@ -1,4 +1,4 @@
-<int, int>PairExt p;
+<~int, int~>PairExt p;
 <<<p>>>;
 <<<p.key>>>;
 <<<p.val>>>;
index 9d804604e7557e05391f72e9244d5f9b8105ae4a..4834e845b5503b9fc3c02fc77beb52d58ba28bf9 100644 (file)
@@ -1,4 +1,4 @@
-<int, float>Map pp;
+<~int, float~>Map pp;
 <<<pp>>>;
 <<<pp.size()>>>;
 <<<pp.set(1, 2)>>>;
index a4e81bae7f4fd7f5812aa0a4c8d986c04bfce098..d33242f2a0e61643b9f0ba6018b63a20a8f9c030 100644 (file)
@@ -1,4 +1,4 @@
-<int>Ptr ptr;
+<~int~>Ptr ptr;
 int i[4];
 for(auto@ a : i)
   <<<*a>>>;
index 8f44fb1a47261225cc74e83b9d3c4771634c97f5..225eb4e6c400741e806b7bdcfd23bf1529f255ca 100644 (file)
@@ -1,22 +1,22 @@
-template<A, B>
+template<~A, B~>
 class C {
   A a;
   B b; 
   fun A test() {
     <<<"lol">>>;
   }
-  template<C>
+  template<~C~>
   fun void test2(C c) {
     <<<c>>>;
   }
 }
 
 //<<<C>>>;
-<int, int>C c;
-<float, int>C d;
-<polar, int>C e;
-<Vec3, int>C f;
-<Object, int>C g;
+<~int, int~>C c;
+<~float, int~>C d;
+<~polar, int~>C e;
+<~Vec3, int~>C f;
+<~Object, int~>C g;
 //C c;
 <<<c.a>>>;
 <<<d.a>>>;
index 339e5f1efbb7aff3ebbf075efc4bb4ba7a9528c2..80dce2b764b303862b19ccaee676dbeb9072b2eb 100644 (file)
@@ -1,4 +1,4 @@
-<int, int>Map pp;
+<~int, int~>Map pp;
 <<<pp>>>;
 <<<pp.size()>>>;
 <<<pp.set(1, 2)>>>;
index 1ce7df8825c51c57860b5b0409b0e1185ed9eb9d..da9a08c8d0151f12e6f19fd818d338e91618213d 100644 (file)
@@ -1,4 +1,4 @@
-<float, int>Pair p;
+<~float, int~>Pair p;
 <<<p>>>;
 1 => p.key;
 2 => p.val;
index 83275c5865ecbd3323e8060cc56c130344f019e2..8b91a6cf4d90b12d540bd26a91224bef04ee901e 100644 (file)
@@ -1,10 +1,10 @@
-template <A>
+template <~A~>
 class C {
   A a;
 }
 
 class D {
-  static <int>C c;
+  static <~int~>C c;
 }
 
 D d;
index c8742fbc97d228f57edc6eae225a9cfce7b3f82b..96b9d1096ceab218e1c3ba42f3cf0e866f8f162d 100644 (file)
@@ -1,5 +1,5 @@
-template<A>
+template<~A~>
 class C {}
 
-<int>C ref;
+<~int~>C ref;
 <<<ref>>>;
index 56e4f518fefbbade7c341246cab1045ca5f1e302..606877145730856c64e32c634f34d7607c3b8597 100644 (file)
@@ -1,4 +1,4 @@
-template<A>
+template<~A~>
 function void test(A a){}
 
 (maybe ? test : test)(1);
index 68c113967f47b7650c47f3e4d732414f4962f9a8..7f7dc18995f485572f335d9e6d182c50464e9ec2 100644 (file)
@@ -1,16 +1,16 @@
-<int, int>Pair p;
-typedef <int, int>Pair lol;
+<~int, int~>Pair p;
+typedef <~int, int~>Pair lol;
 lol t;
 <<<t>>>;
 <<<t.key>>>;
 class C extends lol { int i;}
 C c;
 <<<c.i>>>;
-template <A> class D {
+template <~A~> class D {
   <<<"lol">>>;
   int i;
 }
-typedef <int>D Lol;
+typedef <~int~>D Lol;
 class E extends Lol {
   float f;
 }
diff --git a/util b/util
index e0446891fd79e6ac9f575b8811420427e10f9b8b..9e90c8e8470e94ad319e5bfc75717f6dacb1d6c4 160000 (submodule)
--- a/util
+++ b/util
@@ -1 +1 @@
-Subproject commit e0446891fd79e6ac9f575b8811420427e10f9b8b
+Subproject commit 9e90c8e8470e94ad319e5bfc75717f6dacb1d6c4