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