Skip to content
Snippets Groups Projects
Commit 87db906a authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Comments, slight improvements

parent e0261206
No related branches found
No related tags found
No related merge requests found
...@@ -296,15 +296,27 @@ trait DSL { ...@@ -296,15 +296,27 @@ trait DSL {
/* Definitions */ /* Definitions */
/** Creates a [[FunDef]] given only an [[Identifier]] for the name;
* the (type) parameter [[Identifier]]s will be created fresh by this function.
*
* @param id The [[Identifier]] referring to this function.
* @param tParamNames The names of the type parameters for this function.
* @param builder A function from a Seq of type parameters (which should correspond
* to tParamNames) which, given these type parameters,
* should return
* (1) The sequence of parameters as [[ValDef]]s (see [[TypeToValDef.::]])
* (2) The return type of the function
* (3) A context which, given the parameters, will return the body of the function.
* @return A fresh and juicy [[FunDef]]
*/
def mkFunDef(id: Identifier) def mkFunDef(id: Identifier)
(tParamNames: String*) (tParamNames: String*)
(paramRetBuilder: Seq[TypeParameter] => (builder: Seq[TypeParameter] =>
(Seq[ValDef], Type, Seq[Expr] => Expr) (Seq[ValDef], Type, Seq[Expr] => Expr)
) = { ) = {
val tParams = tParamNames map TypeParameter.fresh val tParams = tParamNames map TypeParameter.fresh
val tParamDefs = tParams map TypeParameterDef val tParamDefs = tParams map TypeParameterDef
val (params, retType, bodyBuilder) = paramRetBuilder(tParams) val (params, retType, bodyBuilder) = builder(tParams)
val fullBody = bodyBuilder(params map (_.toVariable)) val fullBody = bodyBuilder(params map (_.toVariable))
new FunDef(id, tParamDefs, params, retType, fullBody, Set()) new FunDef(id, tParamDefs, params, retType, fullBody, Set())
...@@ -318,10 +330,10 @@ trait DSL { ...@@ -318,10 +330,10 @@ trait DSL {
new AbstractClassDef(id, tParamDefs, children, Set()) new AbstractClassDef(id, tParamDefs, children, Set())
} }
def mkCaseClassDef(id: Identifier) def mkCaseClass(id: Identifier)
(tParamNames: String*) (tParamNames: String*)
(parent: Option[Identifier]) (parent: Option[Identifier])
(fieldBuilder: Seq[TypeParameter] => Seq[ValDef]) = { (fieldBuilder: Seq[TypeParameter] => Seq[ValDef]) = {
val tParams = tParamNames map TypeParameter.fresh val tParams = tParamNames map TypeParameter.fresh
val tParamDefs = tParams map TypeParameterDef val tParamDefs = tParams map TypeParameterDef
val fields = fieldBuilder(tParams) val fields = fieldBuilder(tParams)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment