Commit 98b9cd2d authored by Kevin Modzelewski's avatar Kevin Modzelewski

More minor stuff for the stdlib

parent f9812cf8
......@@ -297,6 +297,17 @@ public:
return true;
}
virtual bool visit_importfrom(AST_ImportFrom* node) {
for (int i = 0; i < node->names.size(); i++) {
AST_alias* alias = node->names[i];
if (alias->asname.size())
doWrite(alias->asname);
else
doWrite(alias->name);
}
return true;
}
static void collect(AST* node, ScopingAnalysis::NameUsageMap* map) {
assert(map);
assert(map->count(node));
......
// Copyright (c) 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cmath>
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/gc_runtime.h"
#include "runtime/inline/boxing.h"
#include "runtime/types.h"
#include "runtime/util.h"
namespace pyston {
BoxedModule* sre_module;
void setupSre() {
sre_module = createModule("_sre", "__builtin__");
sre_module->giveAttr("MAGIC", boxInt(20031017));
sre_module->giveAttr("CODESIZE", boxInt(4));
}
}
......@@ -371,7 +371,8 @@ BoxedModule* builtins_module;
// TODO looks like CPython and pypy put this into an "exceptions" module:
BoxedClass* Exception, *AssertionError, *AttributeError, *TypeError, *NameError, *KeyError, *IndexError, *IOError,
*OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError, *RuntimeError, *ImportError, *StopIteration, *Warning;
*OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError, *RuntimeError, *ImportError, *StopIteration,
*Warning;
const ObjectFlavor exception_flavor(&boxGCHandler, NULL);
Box* exceptionNew1(BoxedClass* cls) {
......@@ -460,8 +461,8 @@ void setupBuiltins() {
ImportError = makeBuiltinException(Exception, "ImportError");
StopIteration = makeBuiltinException(Exception, "StopIteration");
Warning = makeBuiltinException(Exception, "Warning");
/*ImportWarning =*/ makeBuiltinException(Warning, "ImportWarning");
/*PendingDeprecationWarning =*/ makeBuiltinException(Warning, "PendingDeprecationWarning");
/*ImportWarning =*/makeBuiltinException(Warning, "ImportWarning");
/*PendingDeprecationWarning =*/makeBuiltinException(Warning, "PendingDeprecationWarning");
repr_obj = new BoxedFunction(boxRTFunction((void*)repr, UNKNOWN, 1));
builtins_module->giveAttr("repr", repr_obj);
......
......@@ -27,5 +27,7 @@ BoxedModule* posix_module;
void setupPosix() {
posix_module = createModule("posix", "__builtin__");
posix_module->giveAttr("error", OSError);
}
}
......@@ -90,6 +90,9 @@ void setupSys() {
sys_module->giveAttr("warnoptions", new BoxedList());
sys_module->giveAttr("py3kwarning", False);
sys_module->giveAttr("hexversion", boxInt(0x01000000 * PYTHON_VERSION_MAJOR + 0x010000 * PYTHON_VERSION_MINOR
+ 0x0100 * PYTHON_VERSION_MICRO));
}
void setupSysEnd() {
......
......@@ -607,6 +607,7 @@ void setupRuntime() {
setupThread();
setupErrno();
setupPosix();
setupSre();
setupCAPI();
......
......@@ -59,6 +59,7 @@ void setupTime();
void setupThread();
void setupErrno();
void setupPosix();
void setupSre();
void setupSysEnd();
BoxedDict* getSysModulesDict();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment