Example #1
0
        public ParameterDeclaration(Context context, JSParser parser, string identifier)
        {
            m_name    = identifier;
            m_context = (context != null ? context : new Context(parser));

            FunctionScope functionScope = parser != null?parser.ScopeStack.Peek() as FunctionScope : null;

            if (functionScope != null)
            {
                if (functionScope.NameTable.ContainsKey(m_name))
                {
                    //Only happens if there is another parameter declarations with the same name
                    m_context.HandleError(JSError.DuplicateName, m_name, true);
                }
                else
                {
                    m_field = functionScope.AddNewArgumentField(m_name);
                    m_field.OriginalContext = m_context;
                }
            }
            else
            {
                // parameters should only be under a function scope
                m_context.HandleError(
                    JSError.DuplicateName,
                    m_name,
                    true
                    );
            }
        }
Example #2
0
        public ParameterDeclaration(Context context, JSParser parser, string identifier, int position)
        {
            m_name = identifier;
            m_context = (context != null ? context : new Context(parser));

            FunctionScope functionScope = parser != null ? parser.ScopeStack.Peek() as FunctionScope : null;
            if (functionScope != null)
            {
                if (!functionScope.NameTable.ContainsKey(m_name))
                {
                    m_field = functionScope.AddNewArgumentField(m_name);
                    m_field.OriginalContext = m_context;
                    m_field.Position = position;
                }
            }
            else
            {
                // parameters should only be under a function scope
                m_context.HandleError(
                  JSError.DuplicateName,
                  m_name,
                  true
                  );
            }
        }