changeset 126:6e142648b2fe

Wip on compiler issues
author Louis Opter <louis@lse.epita.fr>
date Sun, 18 Aug 2013 12:51:47 -0700
parents 3a92a43a3215
children 72b5b4a62cc5
files rathaxes_compiler_passes_fix_cases_where_self_would_be_incorrectly_resolved.patch rathaxes_compiler_passes_fix_local_variable_resolution_on_method_call.patch series wip_fix_regression_in_rathaxes_compiler_passes_correctly_resolve_chunk_args_subidentifiers.patch
diffstat 4 files changed, 122 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_compiler_passes_fix_cases_where_self_would_be_incorrectly_resolved.patch	Sun Aug 18 12:51:47 2013 -0700
@@ -0,0 +1,89 @@
+# HG changeset patch
+# Parent 3741d7036c658afaa2944b1c0a144bac61b50930
+rathaxes: fix cases where ${self} would be incorrectly resolved
+
+diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+--- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
++++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+@@ -696,7 +696,8 @@
+     case "target_expr":
+         // Is it a variable of a rathaxes type : check in type_map ?
+         if (isEmpty(local_node.prefix) && isEmpty(local_node.suffix)
+-                 && existVariable(theChunk.type_map) && findElement(varName, theChunk.type_map))
++                 && ((existVariable(theChunk.type_map) && findElement(varName, theChunk.type_map))
++                     || varName == "self"))
+         {
+             traceLine("inject<\"__rtx_var__\">:<LOG> Injecting a type mapping (" + varName + ").");
+             // Create the resolverValues for the type resolution:
+@@ -705,21 +706,35 @@
+             rtxNodeArgs(resVal);
+             local self;
+             local self_value;
++            local self_type;
+             // First, try to retrieve value from previous resVals, otherwise build it from chunk
+-            if (rtxNodeArgs_GetArgByName(resolverValues, varName, self) == true)
++            if (varName != "self")
+             {
+-                rtxNodeArg_getValue(self, self_value);
++                if (rtxNodeArgs_GetArgByName(resolverValues, varName, self) == true)
++                {
++                    rtxNodeArg_getValue(self, self_value);
++                }
++                else
++                {
++                    clearVariable(self_value);
++                    cnormNode_TerminalId(self_value, varName);
++                }
++                rtxNodeArgs_AppendArg(resVal, "self", theChunk.type_map[varName], self_value);
++                setall self_type = theChunk.type_map[varName];
+             }
+             else
+             {
+-                clearVariable(self_value);
+-                cnormNode_TerminalId(self_value, varName);
++                // "self" as an identifier means that we're within some Type Template code.
++                // Thus the actual value is the associated ResVal, and the type the template's type itself.
++                if (rtxNodeArgs_GetArgByName(resolverValues, varName, self) == true)
++                {
++                    rtxNodeArg_getValue(self, self_value);
++                }
++                rtxNodeArgs_AppendArg(resVal, "self", self.rtype, self_value);
++                setall self_type = self.rtype;
+             }
+-            rtxNodeArgs_AppendArg(resVal, "self", theChunk.type_map[varName], self_value);
+ 
+-            local qTypeName = rtxRTypeName<theChunk.type_map[varName].type>(
+-                                    theChunk.type_map[varName]
+-                                );
++            local qTypeName = rtxRTypeName<self_type.type>(self_type);
+ 
+             local    mapping;
+             local subParam;
+@@ -727,8 +742,7 @@
+             local subidentifiers;
+             select n in subParam[].name { pushItem subidentifiers; subidentifiers#back = n; }
+ 
+-            if (type_map<qTypeName>(resVal, theChunk.type_map[varName],
+-                                    subidentifiers,
++            if (type_map<qTypeName>(resVal, self_type, subidentifiers,
+                                     local_node, mapping, source_tree) == false)
+             {
+                 traceLine(RED + "[Error] Could not resolve mapping of '"
+@@ -761,7 +775,7 @@
+                     // If there's a resval argument for it, then take the source type from there
+                     // Otherwise, use the chunk's type_map.
+                     if (rtxNodeArg_getRType(self, source_type) == false)
+-                    { ref source_type = theChunk.type_map[varName]; }
++                    { ref source_type = self_type; }
+                     rtxNodeArg_getRType(self, source_type);
+                 }
+                 else
+@@ -769,7 +783,7 @@
+                     // Now resolve the finaltype of the argument -> Retrieve actual param_type
+                     removeVariable(subidentifiers#[0]); // Remove the first identifiers for the type resolution
+                     local result_type;
+-                    if (rtxTypingLookup_ResolveTypeFields(theChunk.type_map[varName], subidentifiers, theChunk, source_tree, source_type) == false)
++                    if (rtxTypingLookup_ResolveTypeFields(self_type, subidentifiers, theChunk, source_tree, source_type) == false)
+                     {
+                         error(RED + "[Error] Could not resolve type fields for variable '"
+                                 + subidentifiers#front + "'" + DEFAULT_COLOR);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_compiler_passes_fix_local_variable_resolution_on_method_call.patch	Sun Aug 18 12:51:47 2013 -0700
@@ -0,0 +1,31 @@
+# HG changeset patch
+# Parent 1b62d6a6307fbfe6ad9ae7137d189f48b7ceb1fb
+rathaxes: fix resolution of local variables on method call
+
+Fix ${local.skb.init()} crazyness.
+
+diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+--- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
++++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
+@@ -388,7 +388,20 @@
+                 // Argument comes from the Chunk, so we retrieve the *real* type
+                 // That will be resolved after the "local" resolution.
+ 
+-                rtxResolve_BuildLocalSelf(subResVal, theChunk, placeHolder, subidentifiers);
++                if (subidentifiers#front == "local")
++                    rtxResolve_BuildLocalSelf(subResVal, theChunk, placeHolder, subidentifiers);
++                else
++                {
++                    local src_arg;
++                    local src_type;
++                    local src_value;
++                    rtxNodeArgs_GetArgByName(src_resVals, "self", src_arg);
++                    if (rtxNodeArg_getRType(src_arg, src_type) == false)
++                        return false;
++                    if (rtxNodeArg_getValue(src_arg, src_value) == false)
++                        return false;
++                    rtxNodeArgs_AppendArg(subResVal, "self", src_type, src_value);
++                }
+                 local local_self;
+                 rtxNodeArgs_GetArgByName(subResVal, "self", local_self);
+                 local local_type;
--- a/series	Sun Aug 04 17:09:42 2013 -0700
+++ b/series	Sun Aug 18 12:51:47 2013 -0700
@@ -4,7 +4,8 @@
 rathaxes_compiler_passes_hack_injection_of_chunks_into_rvalues.patch
 rathaxes_compiler_passes_correctly_resolve_chunk_args_subidentifiers.patch
 rathaxes_compiler_passes_fix_reference_reuse.patch
-wip_fix_regression_in_rathaxes_compiler_passes_correctly_resolve_chunk_args_subidentifiers.patch
+rathaxes_compiler_passes_fix_local_variable_resolution_on_method_call.patch
+rathaxes_compiler_passes_fix_cases_where_self_would_be_incorrectly_resolved.patch
 rathaxes_samples_e1000_add_a_dma_abstraction.patch
 rathaxes_samples_e1000_use_the_dma_abstraction_in_socket.patch
 rathaxes_samples_e1000_add_ethernet_device_alloc_rx_skbuff.patch
--- a/wip_fix_regression_in_rathaxes_compiler_passes_correctly_resolve_chunk_args_subidentifiers.patch	Sun Aug 04 17:09:42 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-# HG changeset patch
-# Parent 67dc97cbe736ead44d6c596eb339829a41c4b847
-diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
---- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
-+++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
-@@ -388,7 +388,20 @@
-                 // Argument comes from the Chunk, so we retrieve the *real* type
-                 // That will be resolved after the "local" resolution.
- 
--                rtxResolve_BuildLocalSelf(subResVal, theChunk, placeHolder, subidentifiers);
-+                if (subidentifiers#front == "local")
-+                    rtxResolve_BuildLocalSelf(subResVal, theChunk, placeHolder, subidentifiers);
-+                else
-+                {
-+                    local src_arg;
-+                    local src_type;
-+                    local src_value;
-+                    rtxNodeArgs_GetArgByName(src_resVals, "self", src_arg);
-+                    if (rtxNodeArg_getRType(src_arg, src_type) == false)
-+                        return false;
-+                    if (rtxNodeArg_getValue(src_arg, src_value) == false)
-+                        return false;
-+                    rtxNodeArgs_AppendArg(subResVal, "self", src_type, src_value);
-+                }
-                 local local_self;
-                 rtxNodeArgs_GetArgByName(subResVal, "self", local_self);
-                 local local_type;