src/NameBinding.cpp
author David Anderson <dvander@alliedmods.net>
Wed Aug 01 22:32:59 2012 -0700 (2012-08-01)
changeset 145 e9d804821c48
parent 137 be919b22085b
child 170 5e4570966ece
permissions -rw-r--r--
Introduced type semantics, completely replacing tag semantics.
     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 {
    49 }
    50 
    51 bool
    52 Variable::needsHeapAllocation()
    53 {
    54     return scope()->kind() == Scope::GLOBAL;
    55 }
    56