/// <summary> /// Map parameter names to positional names. This must match the expectations of the interpreter /// </summary> private static void ParameterPositions(Scope parameterNames, IEnumerable <string> paramNames, NanCodeWriter wr) { parameterNames.PushScope(); var i = 0; foreach (var paramName in paramNames) { if (parameterNames.InScope(NanTags.GetCrushedName(paramName))) { throw new Exception("Duplicate parameter '" + paramName + "'.\r\n" + "All parameter names must be unique in a single function definition."); } var originalReference = NanTags.GetCrushedName(paramName); var parameterReference = Scope.NameFor(i); var parameterByteCode = NanTags.EncodeVariableRef(parameterReference); parameterNames.SetValue(originalReference, parameterByteCode); wr.AddSymbol(originalReference, paramName); wr.AddSymbol(parameterReference, "param[" + i + "]"); i++; } }