~ubuntu-branches/ubuntu/vivid/mozjs24/vivid

« back to all changes in this revision

Viewing changes to js/src/frontend/ParseNode-inl.h

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
2
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 
3
 * This Source Code Form is subject to the terms of the Mozilla Public
 
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
6
 
 
7
#ifndef frontend_ParseNode_inl_h
 
8
#define frontend_ParseNode_inl_h
 
9
 
 
10
#include "frontend/ParseNode.h"
 
11
#include "frontend/SharedContext.h"
 
12
 
 
13
namespace js {
 
14
namespace frontend {
 
15
 
 
16
inline bool
 
17
UpvarCookie::set(JSContext *cx, unsigned newLevel, uint16_t newSlot)
 
18
{
 
19
    // This is an unsigned-to-uint16_t conversion, test for too-high values.
 
20
    // In practice, recursion in Parser and/or BytecodeEmitter will blow the
 
21
    // stack if we nest functions more than a few hundred deep, so this will
 
22
    // never trigger.  Oh well.
 
23
    if (newLevel >= FREE_LEVEL) {
 
24
        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_TOO_DEEP, js_function_str);
 
25
        return false;
 
26
    }
 
27
    level_ = newLevel;
 
28
    slot_ = newSlot;
 
29
    return true;
 
30
}
 
31
 
 
32
inline PropertyName *
 
33
ParseNode::name() const
 
34
{
 
35
    JS_ASSERT(isKind(PNK_FUNCTION) || isKind(PNK_NAME));
 
36
    JSAtom *atom = isKind(PNK_FUNCTION) ? pn_funbox->function()->atom() : pn_atom;
 
37
    return atom->asPropertyName();
 
38
}
 
39
 
 
40
inline JSAtom *
 
41
ParseNode::atom() const
 
42
{
 
43
    JS_ASSERT(isKind(PNK_MODULE) || isKind(PNK_STRING));
 
44
    return isKind(PNK_MODULE) ? pn_modulebox->module()->atom() : pn_atom;
 
45
}
 
46
 
 
47
} /* namespace frontend */
 
48
} /* namespace js */
 
49
 
 
50
#endif /* frontend_ParseNode_inl_h */