view rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch @ 142:cbff597d307e default tip

Wip doc
author Louis Opter <louis@lse.epita.fr>
date Sun, 09 Feb 2014 15:48:57 -0800
parents b22983cb9e3a
children
line wrap: on
line source

# HG changeset patch
# User David Pineau <dav.pineau@gmail.com>, Louis Opter <louis@lse.epita.fr>
# Parent 0f12e80e810de1a9927db1f25dbea49acd73ae3c
rathxes: correctly resolve all variable subidentifier

For example, for a variable like "local.sk_buff.k_dma_handle" type
introspection won't stop at "local.sk_buff" anymore but go all the way
down "local.sk_buff.k_dma_handle" which means that the expression will
yield the correct type.

diff --git a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
--- a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
+++ b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
@@ -752,7 +752,28 @@
             if (findElement(theVar.name, theChunk.type_map))
                 ref theType = theChunk.type_map[theVar.name];
             insert param.rtype;
-            setall param.rtype = theType;
+            if (getArraySize(param.identifiers) > 2)
+            {
+                local subType;
+                local fieldList;
+                foreach field in param.identifiers
+                {
+                    pushItem fieldList;
+                    fieldList#back = field.name;
+                }
+                removeFirstElement(fieldList);
+                removeFirstElement(fieldList);
+                if (rtxTypingLookup_ResolveTypeFields(theType, fieldList, theChunk, theChunk#root /* XXX dummy */, subType) == false)
+                {
+                    error(RED + "[Error] Could not resolve type fields for variable '"
+                          + theVar + "'" + DEFAULT_COLOR);
+                }
+                setall param.rtype = subType;
+            }
+            else
+            {
+                setall param.rtype = theType;
+            }
         }
         pushItem params;
         setall params#back = param.rtype.name;
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
@@ -887,7 +887,7 @@
     local       phName = "_"+local_node#parent.block_idx;
     local       phIdx = 0;
     localref    theParent = local_node#parent.ref_placeholder#parent;
-    if (local_node#parent.type_target != "target_pointcut")
+    if (local_node#parent.type_target != "target_pointcut" && local_node#parent.type_target != "target_expr")
     {
         error(RED + "[Error] inject<\"__rtx_tpl_sequence_call__\">: Wrong target type ("
               + local_node#parent.type_target + ")" + DEFAULT_COLOR);