comparison rathaxes_compiler_passes_hack_injection_of_chunks_into_rvalues.patch @ 114:8eac160e5f1c

WIP, add a new hack on the compiler
author Louis Opter <louis@lse.epita.fr>
date Mon, 22 Jul 2013 00:35:20 -0700
parents
children
comparison
equal deleted inserted replaced
113:b22983cb9e3a 114:8eac160e5f1c
1 # HG changeset patch
2 # User David Pineau <dav.pineau@gmail.com>, Louis Opter <louis@lse.epita.fr>
3 # Parent 98d25045a40891692a5e2e605ad9bccaea17f4ff
4 rathaxes: hack injection of chunks into a rvalue
5
6 It allows to hack a return value into a chunk ::CALL.
7
8 diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
9 --- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws
10 +++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws
11 @@ -33,7 +33,7 @@
12 declare function rtxResolve_WrapChunkIntoType(chunkTree : node);
13
14 declare function rtxResolve_InsertCode(destBlock : node, startIdx : node, phName : value, phIdx : node, sourceNode : node);
15 -declare function rtxResolve_BuildParameterResVals(src_resVals : node, src_params : node, dst_resVals : node, dst_params : node, source_tree : reference, search_chunk : value = true);
16 +declare function rtxResolve_BuildParameterResVals(src_resVals : node, src_params : node, dst_resVals : node, dst_params : node, source_tree : reference, search_chunk : value = true, tpl_seq : value = false);
17 declare function rtxResolve_replaceCalls(theSeq : node, resolverValues : node, source_tree : reference);
18
19
20 @@ -318,20 +318,21 @@
21 dst_resVals : node,
22 dst_params : node,
23 source_tree : reference,
24 - search_chunk : value = true)
25 + search_chunk : value = true,
26 + tpl_seq : value = false)
27 {
28 localref dst_list = dst_params;
29
30 if (rtxNodeArgs(dst_resVals) == false)
31 error(RED + "[Error] Could not intialize argument container." + DEFAULT_COLOR);
32
33 - if (search_chunk)
34 + if (search_chunk && tpl_seq == false)
35 ref dst_list = dst_list.list;
36
37 foreach dst_p in dst_list
38 {
39 local src_p;
40 - if (search_chunk)
41 + if (search_chunk && tpl_seq == false)
42 ref src_p = src_params.list#[index(dst_p)];
43 else
44 ref src_p = src_params#[index(dst_p)];
45 @@ -941,7 +942,7 @@
46
47 // Now, resolve the loaded chunk...
48 local resVals;
49 - rtxResolve_BuildParameterResVals(resolverValues, local_node.body.seqArgs, resVals, chunkTree.tpl_params, source_tree, false);
50 + rtxResolve_BuildParameterResVals(resolverValues, local_node.body.seqArgs, resVals, chunkTree.tpl_params, source_tree, true, true);
51 if (instanceChunk<chunkTree.instanceKey>(resVals, chunkTree.body, source_tree) == false)
52 {
53 traceLine(RED + "[Error] Could not resolve sequence call to " + rtxRTypeFullQualifiedName<"sequence">(tplRtype,dummy) + DEFAULT_COLOR);
54 @@ -949,9 +950,19 @@
55 return false;
56 }
57
58 - insertModifier(theParent, local_node#parent);
59 - startIdx = local_node#parent.block_idx; // retrieve updated startIdx from dummy.
60 - rtxResolve_InsertCode(theParent, startIdx, phName, phIdx, chunkTree.body);
61 + switch (local_node#parent.type_target)
62 + {
63 + case "target_pointcut":
64 + insertModifier(theParent, local_node#parent);
65 + startIdx = local_node#parent.block_idx; // retrieve updated startIdx from dummy.
66 + rtxResolve_InsertCode(theParent, startIdx, phName, phIdx, chunkTree.body);
67 + break ;
68 + case "target_expr":
69 + setall local_node#parent.ref_placeholder = chunkTree.body.block[0].expr;
70 + break ;
71 + default:
72 + error(RED + "[Error] Unmanaged weaving target type: " + local_node#parent.type_target + "." + DEFAULT_COLOR);
73 + }
74
75 return true;
76 }