comparison 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
comparison
equal deleted inserted replaced
112:bfe10def90e3 113:b22983cb9e3a
1 # HG changeset patch
2 # User David Pineau <dav.pineau@gmail.com>, Louis Opter <louis@lse.epita.fr>
3 # Parent 0f12e80e810de1a9927db1f25dbea49acd73ae3c
4 rathxes: correctly resolve all variable subidentifier
5
6 For example, for a variable like "local.sk_buff.k_dma_handle" type
7 introspection won't stop at "local.sk_buff" anymore but go all the way
8 down "local.sk_buff.k_dma_handle" which means that the expression will
9 yield the correct type.
10
11 diff --git a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
12 --- a/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
13 +++ b/rathaxes/compiler/passes/back/rtxIntrospect.inc.cws
14 @@ -752,7 +752,28 @@
15 if (findElement(theVar.name, theChunk.type_map))
16 ref theType = theChunk.type_map[theVar.name];
17 insert param.rtype;
18 - setall param.rtype = theType;
19 + if (getArraySize(param.identifiers) > 2)
20 + {
21 + local subType;
22 + local fieldList;
23 + foreach field in param.identifiers
24 + {
25 + pushItem fieldList;
26 + fieldList#back = field.name;
27 + }
28 + removeFirstElement(fieldList);
29 + removeFirstElement(fieldList);
30 + if (rtxTypingLookup_ResolveTypeFields(theType, fieldList, theChunk, theChunk#root /* XXX dummy */, subType) == false)
31 + {
32 + error(RED + "[Error] Could not resolve type fields for variable '"
33 + + theVar + "'" + DEFAULT_COLOR);
34 + }
35 + setall param.rtype = subType;
36 + }
37 + else
38 + {
39 + setall param.rtype = theType;
40 + }
41 }
42 pushItem params;
43 setall params#back = param.rtype.name;
44 diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
45 --- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
46 +++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
47 @@ -887,7 +887,7 @@
48 local phName = "_"+local_node#parent.block_idx;
49 local phIdx = 0;
50 localref theParent = local_node#parent.ref_placeholder#parent;
51 - if (local_node#parent.type_target != "target_pointcut")
52 + if (local_node#parent.type_target != "target_pointcut" && local_node#parent.type_target != "target_expr")
53 {
54 error(RED + "[Error] inject<\"__rtx_tpl_sequence_call__\">: Wrong target type ("
55 + local_node#parent.type_target + ")" + DEFAULT_COLOR);