jitcraft/Scopes.cpp
changeset 84 eaa43f765cbd
parent 68 b40b0e18a918
child 85 06a0015b6a5c
     1.1 --- a/jitcraft/Scopes.cpp	Wed Jul 18 22:02:11 2012 -0700
     1.2 +++ b/jitcraft/Scopes.cpp	Fri Jul 20 00:03:10 2012 -0700
     1.3 @@ -21,6 +21,7 @@
     1.4  #include "Types.h"
     1.5  #include "TypeManager.h"
     1.6  #include "Strings.h"
     1.7 +#include "CompileContext.h"
     1.8  
     1.9  using namespace ke;
    1.10  
    1.11 @@ -201,15 +202,24 @@
    1.12  }
    1.13  
    1.14  bool
    1.15 -Scope::Bind(ParseTree *tree)
    1.16 +Scope::Bind(CompileContext &cc, ParseTree *tree)
    1.17  {
    1.18      Local<String> name(ZONE());
    1.19      for (size_t i = 0; i < tree->unbound()->length(); i++) {
    1.20          NameProxy *proxy = tree->unbound()->at(i);
    1.21          name = proxy->name();
    1.22          BoundName *binding = tree->scope()->lookup(name);
    1.23 +
    1.24          if (!binding) {
    1.25 -            assert(false);
    1.26 +            cc.reportError(proxy->pos(), Message_IdentifierNotFound, name->chars());
    1.27 +            return false;
    1.28 +        }
    1.29 +
    1.30 +        // We only allow global functions to be late-bound.
    1.31 +        if (binding->kind() != BoundName::FUNCTION ||
    1.32 +            binding->scope()->kind() != Scope::GLOBAL)
    1.33 +        {
    1.34 +            cc.reportError(proxy->pos(), Message_IdentifierNotFound, name->chars());
    1.35              return false;
    1.36          }
    1.37