changeset 66:901af221334b

Adding implementation poinctuts parameters to e1000 sample
author David Pineau <dav.pineau@gmail.com>
date Sat, 18 Feb 2012 15:51:06 +0100
parents 8dc1a3bf372a
children b916396fc577
files PointcutTyping rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch series
diffstat 3 files changed, 163 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PointcutTyping	Sat Feb 18 15:51:06 2012 +0100
@@ -0,0 +1,134 @@
+# HG changeset patch
+# Parent 48c3aacc384cde5a9678d51eeacf6e97262296ff
+rathaxe: compiler: Add pointcut typing
+
+ * rename rtx_seq_param -> rtx_param and  and rtx_seq_parameter -> rtx_parameter_list
+ * Use the renamed parsing rule to parse the argument list of a chunk
+    (factorizing the prototype parsing of a template and a pointcut/chunk)
+
+
+diff --git a/rathaxes/compiler/parse/rtxBack.cwp b/rathaxes/compiler/parse/rtxBack.cwp
+--- a/rathaxes/compiler/parse/rtxBack.cwp
++++ b/rathaxes/compiler/parse/rtxBack.cwp
+@@ -184,25 +184,38 @@
+ /**/    => local lastNode;
+ /**/    #check(cnormNodeBlock_GetLastNode(theBlock, lastNode))
+ 
+-        // Optional Joinpoint (argument of the pointcut)
++        // Optional Joinpoint (argument of the pointcut: if none, parenthesis not required)
+         // Build the chunk node, and retrieve the references to it's internals
+         // (body and parameters)
+-/**/    => local parameters;
++/**/    => local param_types;
++/**/    => local param_identifiers;
+ /**/    => local body;
+-/**/    => local pointcut;
+-/**/    #check(rtxNodeChunk(lastNode, pointcut, parameters, body))
+-        rtx_scoped_identifier(pointcut)
+-/**/      #check(rtxNodeVarList(parameters))
+-        [ rtx_stmt_chunk_params(parameters) ]?
++/**/    => local pointcutRtype;
++/**/    => local pointcutId;
++/**/    #check(rtxNodeChunk(lastNode, pointcutRtype, param_identifiers, body))
++        rtx_scoped_identifier(pointcutId)
++        #check(rtxNodeRType(pointcutRtype, pointcutId, param_types))
++        [ rtx_parameter_list(param_types, param_identifiers) ]?
+ /**/    #continue(sError, "Expected block after chunk declaration.")
+         rtx_chunk_body(body)
+ ;
+ 
++rtx_stmt_chunk_param(theParam : node) ::=
++/**/=> local rtype;
++/**/=> local typeId;
++    rtx_scoped_identifier(typeId) // for the type
++    #check(rtxNodeRType(rtype, typeId, ))
++    identifier:sName // for the identifier's value
++;
++
+ // If there is any parameters to the chunk, we push it into a param list
+ rtx_stmt_chunk_params(theParams : node) ::=
+         '('
+-        [ rtx_var_list(theParams) ]?
+-/**/    #continue(sError, "Expected ')' to end parameter list.")
++            [
++                #pushItem(theParams)
++                rtx_stmt_chunk_param(theParams#back)
++            ]?
++/**/        #continue(sError, "Expected ')' to end parameter list.")
+         ')'
+ ;
+ 
+diff --git a/rathaxes/compiler/parse/rtxCommon.cwp b/rathaxes/compiler/parse/rtxCommon.cwp
+--- a/rathaxes/compiler/parse/rtxCommon.cwp
++++ b/rathaxes/compiler/parse/rtxCommon.cwp
+@@ -131,18 +131,18 @@
+  *
+  */
+ 
+-rtx_seq_param(theParams : node, theIdentifiers : node) ::=
++rtx_param(theParams : node, theIdentifiers : node) ::=
+     #pushItem(theIdentifiers)
+     #pushItem(theParams)
+     rtx_scoped_identifier(theParams#back)
+     [    #readIdentifier:theIdentifiers#back ]?
+ ;
+ 
+-rtx_seq_parameter(theParams : node, theIdentifiers : node) ::=
++rtx_parameter_list(theParams : node, theIdentifiers : node) ::=
+     '('
+     [
+-        rtx_seq_param(theParams, theIdentifiers)
+-        [ ',' rtx_seq_param(theParams, theIdentifiers) ]*
++        rtx_param(theParams, theIdentifiers)
++        [ ',' rtx_param(theParams, theIdentifiers) ]*
+     ]?
+     ')'
+ ;
+@@ -152,5 +152,5 @@
+ /**/=> local params;
+     rtx_scoped_identifier(nameNode)
+     #check(rtxNodeRType(theRtype, nameNode, params))
+-    rtx_seq_parameter(params, theIdentifiers)
++    rtx_parameter_list(params, theIdentifiers)
+ ;
+diff --git a/rathaxes/compiler/parse/rtxMiddle.cwp b/rathaxes/compiler/parse/rtxMiddle.cwp
+--- a/rathaxes/compiler/parse/rtxMiddle.cwp
++++ b/rathaxes/compiler/parse/rtxMiddle.cwp
+@@ -68,8 +68,8 @@
+     #continue(sError, "Expected pointcut name after declaration type.")
+     rtx_scoped_identifier(nameNode)
+     #check(rtxNodeItfPointcutDeclaration(theDecl, theQualif, nameNode, params))
+-    #continue(sError, "Expected parameters to pointcut '"+nameNode.name+"'")
+-    [rtx_pointcut_parameter(params)]?
++    #continue(sError, "Expected parameters to pointcut '"+rtxRtypeName<nameNode.type>(nameNode)+"'")
++    [rtx_pointcut_parameters(params)]
+     #continue(sError, "Missing ';' ending pointcut declaration.")
+     ';'
+ ;
+@@ -165,9 +165,12 @@
+     rtx_scoped_identifier(theParams#back)
+ ;
+ 
+-rtx_pointcut_parameter(theParams : node) ::=
++rtx_pointcut_parameters(theParams : node) ::=
+     '('
+-    [ rtx_pointcut_param(theParams) [ ',' rtx_pointcut_param(theParams) ]* ]?
++    [
++        rtx_pointcut_param(theParams)
++        [ ',' rtx_pointcut_param(theParams) ]*
++    ]?
+     ')'
+ ;
+ 
+diff --git a/rathaxes/compiler/passes/back/rtxMeta.inc.cws b/rathaxes/compiler/passes/back/rtxMeta.inc.cws
+--- a/rathaxes/compiler/passes/back/rtxMeta.inc.cws
++++ b/rathaxes/compiler/passes/back/rtxMeta.inc.cws
+@@ -278,7 +278,7 @@
+ 
+                 tpl_pointcut(thePointcut : node) ::=
+                         "pointcut"
+-/**/                    =>local pointcutId;
++/**/                    => local pointcutId;
+ /**/                    => local theParams;
+ /**/                    => local theDefault;
+ /**/                    #check(rtxNodePointcut(thePointcut, pointcutId, theParams, theDefault))
--- a/rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch	Sat Feb 18 13:36:07 2012 +0100
+++ b/rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch	Sat Feb 18 15:51:06 2012 +0100
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent e24ae3e49b73a2b799765d863f69f0c956ea2c54
+# Parent 0197bb30a5d0fe40c5c67c510a9f076d2272d45d
 # User Louis Opter <louis@lse.epitech.net>, David Pineau <dav.pineau@gmail.com>
 rathaxes: correctly use chunk and template sequences parameters in the e1000 sample
 
@@ -304,7 +304,33 @@
  
                  return 0;
              }
-@@ -121,7 +139,7 @@
+@@ -66,7 +84,7 @@
+         {
+             static int  rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev)
+             {
+-                ${pointcut ::IMPLEMENTATION};
++                ${pointcut ::IMPLEMENTATION(local.skb, local.dev)};
+ 
+                 return 0;
+             }
+@@ -87,7 +105,7 @@
+                 struct rtx_ethernet_dev* rtx_ether_dev =  netdev_priv(dev);
+                 struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
+ 
+-                ${pointcut ::IMPLEMENTATION};
++                ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
+ 
+                 return 0;
+             }
+@@ -114,14 +132,14 @@
+ 
+                 rtx_ether_dev = dev_id;
+                 ctx = &rtx_ether_dev->hw_ctx;
+-                ${pointcut ::IMPLEMENTATION};
++                ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
+ 
+                 return IRQ_NONE;
+             }
          }
      }
  
--- a/series	Sat Feb 18 13:36:07 2012 +0100
+++ b/series	Sat Feb 18 15:51:06 2012 +0100
@@ -1,1 +1,2 @@
 rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch
+PointcutTyping