annotate FixScalarRefPlaceholders @ 109:3523e795bdf9

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