URL:
https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-02 Maxime van Noppen <yabo(a)lrde.epita.fr>
Start work on where clauses : handle inheritance
* Declaration.str: Handle where clauses for simple classes
* (ie non-template).
* Class.str: Handle the inheritance relationship taking care of using
* the correct 'Exact' parameter depending on the class being 'final'
* or not.
Class.str | 45 +++++++++++++++++++++++++++++++++++++++++++++
Declaration.str | 10 +++++++---
2 files changed, 52 insertions(+), 3 deletions(-)
Index: branches/scool-ng/src/scoolt/Class.str
===================================================================
--- branches/scool-ng/src/scoolt/Class.str (revision 104)
+++ branches/scool-ng/src/scoolt/Class.str (revision 105)
@@ -48,3 +48,48 @@
cqualif -> [(CxxType("typename"), "Exact")]
where
<?Some("abstract") <+ ?None()> cqualif
+
+ AddExactParameter(| cqualif, cxx_idf):
+ SimpleType(type) -> StaticFunctionCall(Identifier(type), Parameters([params]))
+ where
+ <ExactParameter(| cqualif, cxx_idf)> [] => params
+
+ ExactParameter(| cqualif, cxx_idf):
+ _ -> Identifier(idf)
+ where
+ <? Some("final")> cqualif
+ ; <? CxxId(idf)> cxx_idf
+ // FIXME : I only have the cxx_idf and rather want the scl_idf to build my SFC
+
+ ExactParameter(| cqualif, cxx_idf):
+ _ -> Identifier("Exact")
+ where
+ <? None()> cqualif
+
+ CheckDaughter(| scl_idf):
+ daughter -> 42 // The result isn't used
+ where
+ <?Identifier(idf)> scl_idf
+ ; <eq> (daughter, idf)
+
+ CheckDaughter(| scl_idf):
+ daughter -> <say(<concat-strings> [ "Error: class name
\"", daughter, "\" doest not match with \"", idf,
"\"" ]); fail>
+ where
+ <?Identifier(idf)> scl_idf
+
+ // FIXME: allow other inheritances than the public one
+ InheritanceToCxx(| cqualif, cxx_idf):
+ mother -> ("public", cxx_mother)
+ where
+ <AddExactParameter(| cqualif, cxx_idf)> mother => cxx_mother
+
+ // Handle where clauses
+
+ ClassWhereClauseToCxx(|cqualif, idf, body):
+ Inherits(daughter, mother) -> CxxClassDecl(cxx_params, cxx_idf, cxx_mother,
cxx_body)
+ where
+ <CheckDaughter(| idf)> daughter // Check if we are the daughter
+ ; <AddExactType(| cqualif)> [] => cxx_params
+ ; <IdentifierToCxx> idf => cxx_idf
+ ; <InheritanceToCxx(| cqualif, cxx_idf)> mother => cxx_mother
+ ; <ClassBodyToCxx> body => cxx_body
Index: branches/scool-ng/src/scoolt/Declaration.str
===================================================================
--- branches/scool-ng/src/scoolt/Declaration.str (revision 104)
+++ branches/scool-ng/src/scoolt/Declaration.str (revision 105)
@@ -60,14 +60,18 @@
////////////////////////////////////////////////////////////////////////////////
- // Class //
+ // Classes //
////////////////////////////////////////////////////////////////////////////////
DeclarationToCxx:
- ClassDefinition(cqualif, idf, wclause, ClassBlock(body)) ->
CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
+ ClassDefinition(cqualif, idf, None(), ClassBlock(body)) ->
CxxClassDecl(cxx_params, cxx_idf, [], cxx_body)
where
<AddExactType(|cqualif)> [] => cxx_params
; <IdentifierToCxx> idf => cxx_idf
- ; <?None> wclause
; <ClassBodyToCxx> body => cxx_body
+ DeclarationToCxx:
+ ClassDefinition(cqualif, idf, Some(ClassWhereClause([wclause])), ClassBlock(body))
-> cxx_code
+ where
+ <ClassWhereClauseToCxx(|cqualif, idf, body)> wclause => cxx_code
+
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)