From: Maxime van Noppen <yabo(a)lrde.epita.fr>
To: transformers-patches(a)lrde.epita.fr, olena-patches(a)lrde.epita.fr
Subject: scool r131: Update tests and add those used in van-noppen.09.dslwc
URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2009-02-11 Maxime van Noppen <yabo(a)lrde.epita.fr>
Update tests and add those used in van-noppen.09.dslwc.
* concept/scool_src/concept_1.scl,
* concept/scool_src/concept_2.scl,
* concept/scool_src/concept_3.scl,
* concept/scool_src/concept_4.scl,
* concept/scool_src/concept_use_1.scl,
* concept/scool_src/concept_use_2.scl: Here.
* concept/scool_src/concept_use_3.scl: New.
* examples/c++_ast/animal_hierarchy.aterm: New.
* examples/c++_ast/point1d_simple.aterm: Remove.
* examples/c++_build/point1d_simple.g++: Remove.
* examples/c++_src/animal_hierarchy.cc: New.
* examples/c++_src/point1d_simple.cc: Remove.
* examples/scool_ast/animal_hierarchy.aterm: New.
* examples/scool_ast/point1d_simple.aterm: Remove.
* examples/scool_ast/sample_animal_hierarchy.aterm: Remove.
* examples/scool_src/animal_hierarchy.scl: New.
* examples/scool_src/container_1.scl: New.
* examples/scool_src/container_2.scl: New.
* examples/scool_src/embeded_c++.scl: New.
* examples/scool_src/fact.scl: New.
* examples/scool_src/meta_identity.scl: New.
* examples/scool_src/meta_type_equality.scl: New.
* examples/scool_src/point1d.scl: New.
* examples/scool_src/point1d_simple.scl: Remove.
* examples/scool_src/sample_animal_hierarchy.scl: Remove.
* examples/scool_src/sample_container.scl: Remove.
---
branches/scool-ng/tests/concept/scool_src/concept_1.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_2.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_3.scl | 4
branches/scool-ng/tests/concept/scool_src/concept_4.scl | 6 -
branches/scool-ng/tests/concept/scool_src/concept_use_1.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_use_2.scl | 2
branches/scool-ng/tests/concept/scool_src/concept_use_3.scl | 30 +++++++
branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm | 1
branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc | 28 ++++++
branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm | 1
branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl | 41 ++++++++++
branches/scool-ng/tests/examples/scool_src/container_1.scl | 16 +++
branches/scool-ng/tests/examples/scool_src/container_2.scl | 28 ++++++
branches/scool-ng/tests/examples/scool_src/embeded_c++.scl | 8 +
branches/scool-ng/tests/examples/scool_src/fact.scl | 7 +
branches/scool-ng/tests/examples/scool_src/meta_identity.scl | 4
branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl | 17 ++++
branches/scool-ng/tests/examples/scool_src/point1d.scl | 18 ++++
18 files changed, 208 insertions(+), 9 deletions(-)
Index: branches/scool-ng/tests/concept/scool_src/concept_use_1.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_1.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_1.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
foo : [ T : type where (T models box) ] (pbox : T) -> void =
Index: branches/scool-ng/tests/concept/scool_src/concept_use_2.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_2.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_2.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
foo : [ T : type where T models box ] (pbox : T) -> void =
Index: branches/scool-ng/tests/concept/scool_src/concept_use_3.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_use_3.scl (revision 0)
+++ branches/scool-ng/tests/concept/scool_src/concept_use_3.scl (revision 131)
@@ -0,0 +1,30 @@
+// Example found in van-noppen.09.dslwc
+
+// Concept declaration
+Box : concept =
+{
+ value_type : type;
+ get_value : () -> value_type;
+ mutable set_value : (value : value_type) -> void;
+}
+
+// Declaration of a class modeling this concept
+Element : class models Box =
+{
+ public
+ {
+ value_type : type = int;
+ get_value : () -> value_type = { -> value_; }
+ mutable set_value : (value : value_type) -> void = { value_ = value; }
+ }
+ private
+ {
+ value_ : value_type;
+ }
+}
+
+// Usage of the concept to restrain a static parameter
+f : [ T : type where T models Box] (val : T) -> void =
+{
+ point : T::value_type = val.get_value();
+}
Index: branches/scool-ng/tests/concept/scool_src/concept_1.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_1.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_1.scl (revision 131)
@@ -2,5 +2,5 @@
{
value : type;
- decl get_value : () -> value;
+ get_value : () -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_2.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_2.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_2.scl (revision 131)
@@ -2,5 +2,5 @@
{
value : type;
- decl set_value : (val : value) -> value;
+ mutable set_value : (val : value) -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_3.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_3.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_3.scl (revision 131)
@@ -2,6 +2,6 @@
{
value : type;
- decl set_value : (val : value) -> value;
- decl get_value : () -> value;
+ mutable set_value : (val : value) -> value;
+ get_value : () -> value;
}
Index: branches/scool-ng/tests/concept/scool_src/concept_4.scl
===================================================================
--- branches/scool-ng/tests/concept/scool_src/concept_4.scl (revision 130)
+++ branches/scool-ng/tests/concept/scool_src/concept_4.scl (revision 131)
@@ -2,7 +2,7 @@
{
value : type;
- decl set_value : (val : value) -> value;
- decl get_value : () -> value;
- decl print_value : () -> void;
+ mutable set_value : (val : value) -> value;
+ get_value : () -> value;
+ print_value : () -> void;
}
Index: branches/scool-ng/tests/examples/c++_ast/point1d_simple.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm
===================================================================
--- branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm (revision 0)
+++ branches/scool-ng/tests/examples/c++_ast/animal_hierarchy.aterm (revision 131)
@@ -0,0 +1 @@
+CxxProgram([CxxProgram("#include
<iostream>"),CxxClassDecl([(CxxType("typename"),"Exact")],CxxId("Animal"),[],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),Const,[])])]),CxxClassDecl([(CxxType("typename"),"Exact")],CxxId("Cat"),[("public",CxxType(CxxId("Animal"),[CxxId("Exact")]))],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),[],Const,[CxxProgram("std::cout
<< \"Meow!\" << std::endl;
")])])]),CxxClassDecl([],CxxId("Dog"),[("public",CxxType(CxxId("Animal"),[CxxId("Dog")]))],[CxxPublic([CxxFun([],CxxType("void"),CxxId("scream"),[],Const,[CxxProgram("std::cout
<< \"Woof!\" << std::endl;
")])])]),CxxFun([],CxxType("void"),CxxId("scream"),[(CxxConstType(CxxRefType(CxxType("Animal"))),CxxId("animal"))],None,[CxxProgram("std::cout
<< animal.scream(); << std::endl; ")])])
Index: branches/scool-ng/tests/examples/c++_src/point1d_simple.cc (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc
===================================================================
--- branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc (revision 0)
+++ branches/scool-ng/tests/examples/c++_src/animal_hierarchy.cc (revision 131)
@@ -0,0 +1,28 @@
+#include <iostream>
+template < typename Exact >
+class Animal
+{
+ public:
+ void scream() const;
+};
+template < typename Exact >
+class Cat : public Animal< Exact >
+{
+ public:
+ void scream() const
+ {
+ std::cout << "Meow!" << std::endl;
+ }
+};
+class Dog : public Animal< Dog >
+{
+ public:
+ void scream() const
+ {
+ std::cout << "Woof!" << std::endl;
+ }
+};
+void scream(const Animal& animal)
+{
+ std::cout << animal.scream(); << std::endl;
+}
Index: branches/scool-ng/tests/examples/scool_ast/sample_animal_hierarchy.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_ast/point1d_simple.aterm (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm
===================================================================
--- branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm (revision 0)
+++ branches/scool-ng/tests/examples/scool_ast/animal_hierarchy.aterm (revision 131)
@@ -0,0 +1 @@
+Program([CxxStatement(Cxx("#include
<iostream>")),ClassDefinition(Identifier("Animal"),None,None,ClassBlock([AccessBlock(Public,[FunctionDeclaration(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")))])])),ClassDefinition(Identifier("Cat"),None,Some(ClassWhereClause([Inherits("Cat",SimpleType("Animal"))])),ClassBlock([AccessBlock(Public,[FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout
<< \"Meow!\" << std::endl;
"))]))])])),ClassDefinition(Identifier("Dog"),Some("final"),Some(ClassWhereClause([Inherits("Dog",SimpleType("Animal"))])),ClassBlock([AccessBlock(Public,[FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout
<< \"Woof!\" << std::endl;
"))]))])])),FunctionDefinition(None,Identifier("scream"),FunctionType(None,ArgumentsDeclaration([TypedId(Identifier("animal"),SimpleType("Animal"))]),SimpleType("void")),FunctionBlock([CxxStatement(Cxx("std::cout
<< animal.scream(); << std::endl; "))]))])
Index: branches/scool-ng/tests/examples/scool_src/sample_animal_hierarchy.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/sample_container.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/point1d_simple.scl (deleted)
===================================================================
Index: branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl (revision 131)
@@ -0,0 +1,41 @@
+|[#include <iostream>]|;
+
+Animal : class =
+{
+ public
+ {
+ scream : () -> void;
+ }
+}
+Cat : class where Cat -> Animal =
+{
+ public
+ {
+ scream : () -> void = { |[ std::cout << "Meow!" <<
std::endl; ]|; }
+ }
+}
+
+Dog : final class where Dog -> Animal =
+{
+ public
+ {
+ scream : () -> void = { |[ std::cout << "Woof!" <<
std::endl; ]|; }
+ }
+}
+
+scream : (animal : Animal) -> void =
+{
+ |[ std::cout << animal.scream(); << std::endl; ]|;
+}
+
+/*
+main : () -> int =
+{
+ var cat : Cat;
+ var dog : Dog;
+
+ scream(cat);
+ scream(dog);
+ -> 0;
+}
+*/
Property changes on: branches/scool-ng/tests/examples/scool_src/animal_hierarchy.scl
___________________________________________________________________
Added: svn:mergeinfo
Index: branches/scool-ng/tests/examples/scool_src/meta_identity.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/meta_identity.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/meta_identity.scl (revision 131)
@@ -0,0 +1,4 @@
+identity : [T : type] -> type =
+{
+ -> T;
+}
Index: branches/scool-ng/tests/examples/scool_src/container_1.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/container_1.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/container_1.scl (revision 131)
@@ -0,0 +1,16 @@
+Container : [T : type] -> class =
+{
+ public
+ {
+ value_type : type = T;
+
+ get : () -> value_type = { -> value; }
+ mutable set : (value : value_type) = { value_ = value; }
+ }
+
+ private
+ {
+ var value_ : value_type;
+ }
+}
+
Property changes on: branches/scool-ng/tests/examples/scool_src/container_1.scl
___________________________________________________________________
Added: svn:mergeinfo
Index: branches/scool-ng/tests/examples/scool_src/container_2.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/container_2.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/container_2.scl (revision 131)
@@ -0,0 +1,28 @@
+container : [T : type] -> class =
+{
+ public
+ {
+ value type : type = T;
+ }
+
+ if [ T == int ]
+ {
+ public
+ {
+ var value : value_type;
+ }
+ }
+ else
+ {
+ public
+ {
+ get : () -> value_type = { -> value_ ; }
+ mutable set : (value : value_type) = { value_ = value; }
+ }
+ private
+ {
+ var value_ : value_type;
+ }
+ }
+}
+
Index: branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/meta_type_equality.scl (revision 131)
@@ -0,0 +1,17 @@
+equal : [T : type] -> class =
+{
+ public
+ {
+ res : type = T;
+ }
+}
+
+not_equal : class = { }
+
+are_equal : [T : type, U : type] -> type =
+{
+ if [ T = U ]
+ -> equal[T];
+ else
+ -> not_equal;
+}
Index: branches/scool-ng/tests/examples/scool_src/embeded_c++.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/embeded_c++.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/embeded_c++.scl (revision 131)
@@ -0,0 +1,8 @@
+// Example found in van-noppen.09.dslwc
+|[ #include <iostream> ]|
+f : (arg: int) -> int =
+{
+ |[ std::cout << arg << std::endl; ]|;
+
+ -> |[ arg + 42 ]|;
+}
Index: branches/scool-ng/tests/examples/scool_src/fact.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/fact.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/fact.scl (revision 131)
@@ -0,0 +1,7 @@
+// Example found in van-noppen.09.dslwc
+fact : [N : unsigned] -> unsigned =
+{
+ if [ N == 0 ]
+ -> 1;
+ -> N + fact[N - 1];
+}
Index: branches/scool-ng/tests/examples/scool_src/point1d.scl
===================================================================
--- branches/scool-ng/tests/examples/scool_src/point1d.scl (revision 0)
+++ branches/scool-ng/tests/examples/scool_src/point1d.scl (revision 131)
@@ -0,0 +1,18 @@
+// Example found in van-noppen.09.dslwc
+point1d : class =
+{
+ public
+ {
+ point_type: type = int;
+
+ make : () = { x_ = 0; }
+ make(x : point_type) = { x_ = x; }
+
+ get_x : () -> point_type = { -> x; }
+ mutable set_x : (x : point_type) -> point_type = { x_ = x; }
+ }
+ private
+ {
+ var x_ : point_type;
+ }
+}
Index: branches/scool-ng/tests/examples/c++_build/point1d_simple.g++ (deleted)
===================================================================