view FixScalarRefUnstrictBug @ 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
line wrap: on
line source

# HG changeset patch
# User David Pineau <dav.pineau@gmail.com>
# Parent e1ea51d560d0e95cb29d42c30dbfe2dff5597e8b
Work around an unstrict cnorm bug issue concerning the function declarations.

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
@@ -213,9 +213,65 @@
                             { rtxPH_compile<item.type>(item, compile, node_idx); }
                         }
                 }
-                // recurse param list
+                // recurse param list + Resolve unknown before going down.
                 if (existVariable(ctype_ref.param))
-                { rtxPH_compile<ctype_ref.param.type>(ctype_ref.param, compile, node_idx);}
+                {
+                    // XXX FIXME
+                    // This is a workaround for a bug involving the unstrict cnorm.
+                    // We patch-up the function's arg's types and names before checking further.
+                    local argnames;
+                    foreach param in ctype_ref.param.block
+                    {
+                        localref theType = param;
+                        localref param_ctype = theType.ctype;
+
+                        //First setup the iterator over the right param to retrieve name.
+                        local name_it;
+                        local it_idx = 0;
+                        createIterator(name_it, ctype_ref.param.map);
+                        while (it_idx != index(param))
+                        {
+                            next(name_it);
+                            increment(it_idx);
+                        }
+                        local theName = key(name_it);
+
+                        if (existVariable(param_ctype.unknown))
+                        {
+                            local placeholder_key = false;
+                            foreach token in param_ctype.unknown
+                            {
+                                local theKey = key(token);
+                                if (rtxPH_havePlaceHolder(theKey))
+                                {
+                                    placeholder_key = theKey;
+                                    break ;
+                                }
+                            }
+                            if (placeholder_key == false) // no token found
+                            {
+                                param_ctype.identifier = param_ctype.unknown#back;
+                                removeVariable(param_ctype.unknown);
+                            }
+                            else // placeholder found -> Set as type, use other var as name.
+                            {
+                                param_ctype.identifier = placeholder_key;
+                                removeVariable(param_ctype.unknown[placeholder_key]);
+                                local last_it;
+                                createReverseIterator(last_it, param_ctype.unknown);
+                                theName = key(last_it);
+                                removeVariable(param_ctype.unknown);
+                                insert param.name = theName;
+                            }
+                        }
+                        insert argnames[theName] = index(param);
+                    }
+                    setall ctype_ref.param.map = argnames;
+
+                    rtxPH_compile<ctype_ref.param.type>(ctype_ref.param, compile, node_idx);
+                }
+
+
                 // if type is enum
                 if (existVariable(ctype_ref.enum))
                 {