src/NameBinding.cpp
author David Anderson <dvander@alliedmods.net>
Sat Jul 28 16:42:38 2012 -0700 (2012-07-28)
changeset 108 9dcf58a17d32
parent 92 e3974e7360e9
child 137 be919b22085b
permissions -rw-r--r--
Stop using ccache on OS X.
     1 /*
     2  * Copyright (C) 2012 David Anderson
     3  *
     4  * This file is part of JITCraft.
     5  *
     6  * JITCraft is free software: you can redistribute it and/or modify it under
     7  * the terms of the GNU General Public License as published by the Free
     8  * Software Foundation, either version 3 of the License, or (at your option)
     9  * any later version.
    10  * 
    11  * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
    12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License along with
    16  * JITCraft. If not, see http://www.gnu.org/licenses/.
    17  */
    18 #include "NameBinding.h"
    19 #include "Strings.h"
    20 #include "Zone.h"
    21 #include "Scopes.h"
    22 #include "Spaces-inl.h"
    23 #include "Heap-inl.h"
    24 
    25 using namespace ke;
    26 
    27 BoundName::BoundName(Scope *scope, Handle<String> name, const SourcePosition &pos)
    28   : scope_(scope),
    29     name_(name),
    30     type_(NULL),
    31     pos_(pos)
    32 {
    33 }
    34 
    35 NamedFunction::NamedFunction(Scope *scope, Handle<String> name, const SourcePosition &pos,
    36                              TokenKind token)
    37   : BoundName(scope, name, pos),
    38     token_(token),
    39     isVariadicNative_(false)
    40 {
    41 }
    42 
    43 Variable::Variable(Scope *scope, Handle<String> name, const SourcePosition &pos)
    44   : BoundName(scope, name, pos),
    45     location_(UNALLOCATED)
    46 {
    47 }
    48 
    49 bool
    50 Variable::needsHeapAllocation()
    51 {
    52     return scope()->kind() == Scope::GLOBAL;
    53 }