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