Mercurial > archived > louis > epitech > mq > rathaxes
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FixScalarRefPlaceholders Mon Mar 25 01:17:56 2013 +0100 @@ -0,0 +1,81 @@ +# HG changeset patch +# Parent ff998c040d556c284f488a9565ddd38bb21a5737 +Fix Scalar/Ref placeholders annotations by adding a 'copy' that does not alter the current state + +diff --git a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws +--- a/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws ++++ b/rathaxes/compiler/passes/back/rtxPlaceHolders.inc.cws +@@ -194,12 +194,13 @@ + // in unstrict mode + if (existVariable(ctype_ref.unknown) && $getArraySize(ctype_ref.unknown) > 0$) + { +- ctype_ref.identifier = ctype_ref.unknown#back; +- removeVariable(ctype_ref.unknown); ++ ctype_ref.identifier = ctype_ref.unknown#back; ++ removeVariable(ctype_ref.unknown); + } + // name of a type + if (existVariable(ctype_ref.identifier) && rtxPH_havePlaceHolder(ctype_ref.identifier)) + { rtxPH_mapPlaceHolder(ctype_ref.identifier, compile, node_idx, "target_decl"); } ++ + // composed + if (existVariable(ctype_ref.list)) + { +@@ -266,7 +267,7 @@ + // So do not bother with subtypes and check them all and then recurse. + function rtxPH_compile<"__expr__">(local_node : node, compile : node, node_idx : value) + { +- if (!existVariable(this.phtype)) insert this.phtype = "scalar";///// ++ if (!existVariable(this.phtype)) insert this.phtype = "copy";//// set to default + // left for bin operator + if (existVariable(local_node.left)) + { +@@ -275,7 +276,7 @@ + // all post expr case [] or (), are pointer + if (local_node.expr_type == "__postexpr__") { insert this.phtype = "pointer";}//// + rtxPH_compile<local_node.left.type>(local_node.left, compile, node_idx); +- insert this.phtype = "scalar";//// ++ insert this.phtype = "copy";//// set to default + } + // right for bin operator + if (existVariable(local_node.right)) +@@ -283,7 +284,7 @@ + // the unary * + if (local_node.operator == "*" && local_node.expr_type == "__unary__") {insert this.phtype = "pointer";}//// + rtxPH_compile<local_node.right.type>(local_node.right, compile, node_idx); +- insert this.phtype = "scalar";//// ++ insert this.phtype = "copy";//// set to default + } + // if,while + if (existVariable(local_node.condition)) +diff --git a/rathaxes/compiler/passes/common/rtxResolve.inc.cws b/rathaxes/compiler/passes/common/rtxResolve.inc.cws +--- a/rathaxes/compiler/passes/common/rtxResolve.inc.cws ++++ b/rathaxes/compiler/passes/common/rtxResolve.inc.cws +@@ -177,6 +177,10 @@ + if (out_type == "ref") + out_type = "pointer"; + ++ // Then, check if we need any changes or not for the out_type ++ if (out_type == "copy") // Copy means that we keep the current state, whether pointer or scalar. ++ return true; ++ + // make sure in and out types are either scalar or ref + if ((in_type != "scalar" && in_type != "pointer") + || (out_type != "scalar" && out_type != "pointer")) +@@ -593,7 +597,7 @@ + // We want to set the mangled typedef name into the ctype's identifier: + // (equivalent of: theDecl.ctype.identifier = COMPUTED_NAME;) + local_node#parent.ref_placeholder.identifier = rtxResolve_MangleTypeName(theRtype, theRtype.qualifier != "scalar"); +- ++ + return true; + } + +@@ -756,7 +760,6 @@ + { error(RED + "[Error] Cannot transcribe an expression from " + in_type + " to " + out_type + DEFAULT_COLOR); } + setall local_node#parent.ref_placeholder = mapping; + } +- + } + else if (isBuiltinVariable(varName)) // Mapping for a builtin type + {