annotate FixScalarRefCasts @ 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 2a7d28a3e2d86d36ddfc77ad8ce73c22eadcc718
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 Add .ref and .scalar to rathaxes types
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/node/rtxNodeBack.inc.cws b/rathaxes/compiler/node/rtxNodeBack.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/node/rtxNodeBack.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/node/rtxNodeBack.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 @@ -19,7 +19,7 @@
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
10 declare function rtxNodePlaceHolder(local_node : node);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
11 declare function rtxNodeCall(local_node : node, theVars : node, theChunk : node, out_ref_params : reference);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
12 declare function rtxNodeSequenceCall(local_node : node, name : node, args : node);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
13 -declare function rtxNodeCast(local_node : node, varName : value, typeId : node);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
14 +declare function rtxNodeCast(local_node : node, varName : value, typeId : node, sQualifier : value);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
15 // Tool functions for the resolution/generation
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
16 declare function rtxNodeResVal_GetField(resolver_values : node, idList : node, out_ref : reference);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
17 declare function rtxNodeResVal(local_node : node);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
18 @@ -233,7 +233,7 @@
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
19 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
20 }
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 -function rtxNodeCast(local_node : node, varName : value, typeId : node)
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
23 +function rtxNodeCast(local_node : node, varName : value, typeId : node, sQualifier : value)
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 rtxNode(local_node);
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
26 local_node.type = "__rtx_tpl_cast__";
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
27 @@ -244,6 +244,8 @@
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
28 local dummy;
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 (rtxNodeRType(local_node.rtype, typeId, dummy) == false)
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
30 return false;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
31 + if (rtxNodeRType_SetQualifier(local_node.rtype, sQualifier) == false)
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
32 + return false;
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 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
35 }
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
36 diff --git a/rathaxes/compiler/passes/back/rtxMeta.inc.cws b/rathaxes/compiler/passes/back/rtxMeta.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
37 --- a/rathaxes/compiler/passes/back/rtxMeta.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
38 +++ b/rathaxes/compiler/passes/back/rtxMeta.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
39 @@ -292,15 +292,20 @@
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 // Here, we allow casting a local C variable into a rathaxes type. This casts lasts for the current chunk's scope.
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
42 tpl_cast(theCast : node) ::=
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
43 +/**/ => local sQualifier = "scalar";
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
44 "cast"
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
45 + #continue(sError, "A cast can only be applied to a local variable (\"local.\" is expected).")
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
46 => local typeId;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
47 - #continue(sError, "A cast can only be applied to a local variable (\"local.\" is expected).")
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
48 "local" '.' rootidentifier:varName
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
49 #continue(sError, "Expected 'as' token for a rathaxes cast.")
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
50 "as"
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
51 #continue(sError, "Expected Type name for casting type.")
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
52 rtx_scoped_identifier(typeId, false)
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
53 - #check(rtxNodeCast(theCast, varName, typeId))
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
54 + [
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
55 + "."
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
56 + tpl_type_qualifier:sQualifier
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
57 + ]?
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
58 + #check(rtxNodeCast(theCast, varName, typeId, sQualifier))
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
59 ;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
60
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff changeset
61 tpl_type_qualifier ::=