Commit d5f614a1 authored by Kenton Varda's avatar Kenton Varda

Switch to the new compiler. All tests pass\! Need to submit bootstrap copies…

Switch to the new compiler.  All tests pass\!  Need to submit bootstrap copies of the generated code used by the compiler itself.  These bootstrap copies are still built by the old compiler at the moment.
parent d946e77b
......@@ -42,7 +42,7 @@ EXTRA_DIST = \
LICENSE.txt \
$(test_capnpc_inputs)
CLEANFILES = $(capnpc_outputs) $(test_capnpc_outputs) capnpc_middleman test_capnpc_middleman
CLEANFILES = $(test_capnpc_outputs) capnpc_middleman test_capnpc_middleman
# Deletes all the files generated by autoreconf.
MAINTAINERCLEANFILES = \
......@@ -225,7 +225,7 @@ test_capnpc_outputs = \
src/capnp/test-import.capnp.c++ \
src/capnp/test-import.capnp.h
BUILT_SOURCES = $(test_capnpc_outputs) $(capnpc_outputs)
BUILT_SOURCES = $(test_capnpc_outputs)
check_PROGRAMS = capnp-test
capnp_test_LDADD = gtest/lib/libgtest.la gtest/lib/libgtest_main.la libcapnp.la
......
// Generated code, DO NOT EDIT
#include "c++.capnp.h"
namespace capnp {
namespace annotations {
} // namespace
} // namespace
namespace capnp {
namespace schemas {
} // namespace schemas
namespace _ { // private
} // namespace _ (private)
} // namespace capnp
// Generated code, DO NOT EDIT
#ifndef CAPNP_INCLUDED_d8bf766fe2146a6566a69e5eae0af6f1
#define CAPNP_INCLUDED_d8bf766fe2146a6566a69e5eae0af6f1
#include <capnp/generated-header-support.h>
namespace capnp {
namespace annotations {
} // namespace
} // namespace
namespace capnp {
namespace schemas {
} // namespace schemas
namespace _ { // private
} // namespace capnp
} // namespace _ (private)
namespace capnp {
namespace annotations {
} // namespace
} // namespace
#endif // CAPNP_INCLUDED_d8bf766fe2146a6566a69e5eae0af6f1
......@@ -32,6 +32,15 @@ fi
INPUT=$1
case "$INPUT" in
*capnp/c++.capnp | \
*capnp/schema.capnp | \
*capnp/compiler/lexer.capnp | \
*capnp/compiler/grammar.capnp )
exit 0
;;
esac
echo findProvider special:ekam-interceptor
read INTERCEPTOR
......@@ -40,13 +49,22 @@ if test "$INTERCEPTOR" = ""; then
exit 1
fi
echo findProvider file:capnpc
read CAPNPC
echo findProvider file:capnp
read CAPNP
if test "$CAPNP" = ""; then
echo "error: couldn't find capnp." >&2
exit 1
fi
echo findProvider file:capnpc-c++
read CAPNPC_CXX
if test "$CAPNPC" = ""; then
CAPNPC=capnpc
if test "$CAPNPC_CXX" = ""; then
echo "error: couldn't find capnpc-c++." >&2
exit 1
fi
# When exception stack traces are needed, add: +RTS -xc -RTS
LD_PRELOAD=$INTERCEPTOR DYLD_FORCE_FLAT_NAMESPACE= DYLD_INSERT_LIBRARIES=$INTERCEPTOR \
$CAPNPC -I. -oc++ "$INPUT" 3>&1 4<&0 >&2
$CAPNP compile -I. -o$CAPNPC_CXX "$INPUT" 3>&1 4<&0 >&2
This diff is collapsed.
......@@ -95,6 +95,7 @@ public:
kj::Maybe<ResolvedName> resolve(const DeclName::Reader& name) const override;
kj::Maybe<Schema> resolveBootstrapSchema(uint64_t id) const override;
kj::Maybe<schema::Node::Reader> resolveFinalSchema(uint64_t id) const override;
kj::Maybe<uint64_t> resolveImport(kj::StringPtr name) const override;
private:
const CompiledModule* module; // null iff isBuiltin is true
......@@ -804,6 +805,14 @@ kj::Maybe<schema::Node::Reader> Compiler::Node::resolveFinalSchema(uint64_t id)
}
}
kj::Maybe<uint64_t> Compiler::Node::resolveImport(kj::StringPtr name) const {
KJ_IF_MAYBE(m, module->importRelative(name)) {
return m->getRootNode().getId();
} else {
return nullptr;
}
}
// =======================================================================================
Compiler::CompiledModule::CompiledModule(
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -687,6 +687,10 @@ static void findImports(DynamicValue::Reader value, std::set<kj::StringPtr>& out
}
break;
case DynamicValue::UNION:
findImports(value.as<DynamicUnion>().get(), output);
break;
default:
break;
}
......@@ -699,6 +703,9 @@ void NodeTranslator::compileFile(Declaration::Reader decl, schema::FileNode::Bui
auto list = builder.initImports(imports.size());
auto iter = imports.begin();
for (auto element: list) {
KJ_IF_MAYBE(i, resolver.resolveImport(*iter)) {
element.setId(*i);
}
element.setName(*iter++);
}
KJ_ASSERT(iter == imports.end());
......
......@@ -72,6 +72,9 @@ public:
// Throws an exception if the id is not one that was found by calling resolve() or by
// traversing other schemas. Returns null if the ID is recognized, but the corresponding
// schema node failed to be built for reasons that were already reported.
virtual kj::Maybe<uint64_t> resolveImport(kj::StringPtr name) const = 0;
// Get the ID of an imported file given the import path.
};
NodeTranslator(const Resolver& resolver, const ErrorReporter& errorReporter,
......
......@@ -346,10 +346,10 @@ TEST(Encoding, UnionLayout) {
EXPECT_EQ(UnionState({0,12,0,0}, 512), INIT_UNION(getUnion1().setU1f1sp("1")));
EXPECT_EQ(UnionState({0,13,0,0}, -1), INIT_UNION(getUnion1().setU1f2s0(Void::VOID)));
EXPECT_EQ(UnionState({0,14,0,0}, 128), INIT_UNION(getUnion1().setU1f2s1(1)));
EXPECT_EQ(UnionState({0,15,0,0}, 128), INIT_UNION(getUnion1().setU1f2s8(1)));
EXPECT_EQ(UnionState({0,16,0,0}, 128), INIT_UNION(getUnion1().setU1f2s16(1)));
EXPECT_EQ(UnionState({0,17,0,0}, 128), INIT_UNION(getUnion1().setU1f2s32(1)));
EXPECT_EQ(UnionState({0,14,0,0}, 65), INIT_UNION(getUnion1().setU1f2s1(1)));
EXPECT_EQ(UnionState({0,15,0,0}, 72), INIT_UNION(getUnion1().setU1f2s8(1)));
EXPECT_EQ(UnionState({0,16,0,0}, 80), INIT_UNION(getUnion1().setU1f2s16(1)));
EXPECT_EQ(UnionState({0,17,0,0}, 96), INIT_UNION(getUnion1().setU1f2s32(1)));
EXPECT_EQ(UnionState({0,18,0,0}, 128), INIT_UNION(getUnion1().setU1f2s64(1)));
EXPECT_EQ(UnionState({0,19,0,0}, 512), INIT_UNION(getUnion1().setU1f2sp("1")));
......
......@@ -55,7 +55,7 @@ Schema Schema::getDependency(uint64_t id) const {
}
}
KJ_FAIL_REQUIRE("Requested ID not found in dependency table.", id);
KJ_FAIL_REQUIRE("Requested ID not found in dependency table.", kj::hex(id));
return Schema();
}
......
......@@ -156,17 +156,7 @@ struct FileNode {
imports @0 :List(Import);
struct Import {
id @0 :Id;
# DEPRECATED: ID of the imported file. This is no longer filled in because it is hostile to
# lazy importing: since this import list appears in the FileNode, and since the FileNode must
# necessarily be cosntructed if any schemas in the file are used, the implication of listing
# import IDs here is that if a schema file is used at all, all of its imports must be parsed,
# just to get their IDs. We'd much rather delay parsing a file until something inside it is
# actually used.
#
# In any case, this import list's main reason for existing is to make it easy to generate
# the appropriate #include statements in C++. The IDs of files aren't needed for that.
#
# TODO(someday): Perhaps provide an alternative way to identify the remote file.
# ID of the imported file.
name @1 :Text;
# Name which *this* file used to refer to the foreign file. This may be a relative name.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -216,7 +216,7 @@ struct TestUnion {
u1f0sp @30: Text;
u1f1sp @31: Text;
# Pack more stuff into union1 -- should go into same space as u1f0s64.
# Pack more stuff into union1 -- each should go into the same space as corresponding u1f0s*.
u1f2s0 @32: Void;
u1f2s1 @33: Bool;
u1f2s8 @34: Int8;
......
......@@ -233,14 +233,16 @@ void ArrayOutputStream::write(const void* src, size_t size) {
// =======================================================================================
AutoCloseFd::~AutoCloseFd() noexcept(false) {
unwindDetector.catchExceptionsIfUnwinding([&]() {
// Don't use SYSCALL() here because close() should not be repeated on EINTR.
if (fd >= 0 && close(fd) < 0) {
KJ_FAIL_SYSCALL("close", errno, fd) {
break;
if (fd >= 0) {
unwindDetector.catchExceptionsIfUnwinding([&]() {
// Don't use SYSCALL() here because close() should not be repeated on EINTR.
if (close(fd) < 0) {
KJ_FAIL_SYSCALL("close", errno, fd) {
break;
}
}
}
});
});
}
}
FdInputStream::~FdInputStream() noexcept(false) {}
......
......@@ -126,8 +126,8 @@ main = do
-- TODO(someday): We should perhaps determine the compiler binary's location and search its
-- ../include as well. Also, there should perhaps be a way to tell the compiler not to search
-- these hard-coded default paths.
let searchPath = ["/usr/local/include", "/usr/include"] ++
[dir | SearchPathOpt dir <- options]
let searchPath = [dir | SearchPathOpt dir <- options] ++
["/usr/local/include", "/usr/include"]
srcPrefixes = [addTrailingSlash prefix | SrcPrefixOpt prefix <- options]
addTrailingSlash path =
if not (null path) && last path /= '/'
......
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