Mercurial > archived > louis > epitech > mq > rathaxes
comparison FixScalarRefPlaceholders @ 106:976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
author | David Pineau <dav.pineau@gmail.com> |
---|---|
date | Mon, 25 Mar 2013 01:17:56 +0100 |
parents | |
children | 3523e795bdf9 |
comparison
equal
deleted
inserted
replaced
105:fb20f01ea997 | 106:976a4b87803f |
---|---|
1 # HG changeset patch | |
2 # Parent ff998c040d556c284f488a9565ddd38bb21a5737 | |
3 Fix Scalar/Ref placeholders annotations by adding a 'copy' that does not alter the current state | |
4 | |
5 diff --git a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws | |
6 --- a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws | |
7 +++ b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws | |
8 @@ -194,12 +194,13 @@ | |
9 // in unstrict mode | |
10 if (existVariable(ctype_ref.unknown) && $getArraySize(ctype_ref.unknown) > 0$) | |
11 { | |
12 - ctype_ref.identifier = ctype_ref.unknown#back; | |
13 - removeVariable(ctype_ref.unknown); | |
14 + ctype_ref.identifier = ctype_ref.unknown#back; | |
15 + removeVariable(ctype_ref.unknown); | |
16 } | |
17 // name of a type | |
18 if (existVariable(ctype_ref.identifier) && rtxPH_havePlaceHolder(ctype_ref.identifier)) | |
19 { rtxPH_mapPlaceHolder(ctype_ref.identifier, compile, node_idx, "target_decl"); } | |
20 + | |
21 // composed | |
22 if (existVariable(ctype_ref.list)) | |
23 { | |
24 @@ -266,7 +267,7 @@ | |
25 // So do not bother with subtypes and check them all and then recurse. | |
26 function rtxPH_compile<"__expr__">(local_node : node, compile : node, node_idx : value) | |
27 { | |
28 - if (!existVariable(this.phtype)) insert this.phtype = "scalar";///// | |
29 + if (!existVariable(this.phtype)) insert this.phtype = "copy";//// set to default | |
30 // left for bin operator | |
31 if (existVariable(local_node.left)) | |
32 { | |
33 @@ -275,7 +276,7 @@ | |
34 // all post expr case [] or (), are pointer | |
35 if (local_node.expr_type == "__postexpr__") { insert this.phtype = "pointer";}//// | |
36 rtxPH_compile<local_node.left.type>(local_node.left, compile, node_idx); | |
37 - insert this.phtype = "scalar";//// | |
38 + insert this.phtype = "copy";//// set to default | |
39 } | |
40 // right for bin operator | |
41 if (existVariable(local_node.right)) | |
42 @@ -283,7 +284,7 @@ | |
43 // the unary * | |
44 if (local_node.operator == "*" && local_node.expr_type == "__unary__") {insert this.phtype = "pointer";}//// | |
45 rtxPH_compile<local_node.right.type>(local_node.right, compile, node_idx); | |
46 - insert this.phtype = "scalar";//// | |
47 + insert this.phtype = "copy";//// set to default | |
48 } | |
49 // if,while | |
50 if (existVariable(local_node.condition)) | |
51 diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws | |
52 --- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws | |
53 +++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws | |
54 @@ -177,6 +177,10 @@ | |
55 if (out_type == "ref") | |
56 out_type = "pointer"; | |
57 | |
58 + // Then, check if we need any changes or not for the out_type | |
59 + if (out_type == "copy") // Copy means that we keep the current state, whether pointer or scalar. | |
60 + return true; | |
61 + | |
62 // make sure in and out types are either scalar or ref | |
63 if ((in_type != "scalar" && in_type != "pointer") | |
64 || (out_type != "scalar" && out_type != "pointer")) | |
65 @@ -593,7 +597,7 @@ | |
66 // We want to set the mangled typedef name into the ctype's identifier: | |
67 // (equivalent of: theDecl.ctype.identifier = COMPUTED_NAME;) | |
68 local_node#parent.ref_placeholder.identifier = rtxResolve_MangleTypeName(theRtype, theRtype.qualifier != "scalar"); | |
69 - | |
70 + | |
71 return true; | |
72 } | |
73 | |
74 @@ -756,7 +760,6 @@ | |
75 { error(RED + "[Error] Cannot transcribe an expression from " + in_type + " to " + out_type + DEFAULT_COLOR); } | |
76 setall local_node#parent.ref_placeholder = mapping; | |
77 } | |
78 - | |
79 } | |
80 else if (isBuiltinVariable(varName)) // Mapping for a builtin type | |
81 { |