diff rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch @ 113:b22983cb9e3a

WIP, thanks joa for some fixes on the compiler
author Louis Opter <louis@lse.epita.fr>
date Sat, 20 Jul 2013 20:45:39 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_compiler_passes_correctly_resolve_all_variables_subidentifiers.patch	Sat Jul 20 20:45:39 2013 -0700
@@ -0,0 +1,55 @@
+# 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);