Mercurial > archived > louis > epitech > mq > rathaxes
annotate FixScalarRefCasts @ 107:f42751b8ca99
Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
author | Louis Opter <louis@lse.epita.fr> |
---|---|
date | Sun, 24 Mar 2013 21:47:39 -0700 |
parents | 976a4b87803f |
children | 3523e795bdf9 |
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 |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
2 # Parent 9fcbcd542e91d0b05c087f4c44cb26c6f4df9ddc |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
3 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
|
4 |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
5 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
|
6 --- 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
|
7 +++ 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
|
8 @@ -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
|
9 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
|
10 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
|
11 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
|
12 -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
|
13 +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
|
14 // 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
|
15 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
|
16 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
|
17 @@ -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
|
18 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
|
19 } |
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 -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
|
22 +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
|
23 { |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
24 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
|
25 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
|
26 @@ -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
|
27 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
|
28 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
|
29 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
|
30 + 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
|
31 + 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
|
32 |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
33 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
|
34 } |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
35 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
|
36 --- 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
|
37 +++ 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
|
38 @@ -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
|
39 |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
40 // 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
|
41 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
|
42 +/**/ => 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
|
43 "cast" |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
44 + #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
|
45 => 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
|
46 - #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
|
47 "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
|
48 #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
|
49 "as" |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
50 #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
|
51 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
|
52 - #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
|
53 + [ |
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 + 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
|
56 + ]? |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
57 + #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
|
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 |
976a4b87803f
Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents:
diff
changeset
|
60 tpl_type_qualifier ::= |