-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major overhaul of the AST infrastructure.
High-level summary of the most important changes: - Restructure the main AST pass loop. Instead of running passes from all plugins interleaved at the same time, we now run plugins sequentially; specifically first Spicy, then HILTI. After each plugin's run, we have a fully resolved AST that's then transformed into the starting AST for the subsequent plugin. Note that the Spicy plugin still calls into the HILTI plugin for resolving its AST: that's because the two representations share a lot of semantics so that we can outsource a bunch of stuff that the Spicy AST needs to do to the HILTI plugin --- it's the same logic. As part of this, we regroup the visitors: the `{resolver,operator-resolver,id-resolver}.cc` are mostly merged into a single `resolver.cc`, plus a new `normalizer.cc` where some stuff moved that enforces some constraints on the AST before anything else. `visitors/apply-coercions.cc` moved to `visitors/coercer.cc`, and the former `coercer.cc` moved out of the visitors directory one level up into `coercion.cc` because it's not an AST pass. - New AST structure that doesn't compute anything dynamically anymore; all information is stored in AST nodes. We now almost exclusively pass around references to nodes, no longer copies. We got some new helper classes for that: `hilti::optional_ref<T>`, `hilti::node::Set<T>`, `hilti::node::Range<T>`. This especially includes replacing all dynamically computed types with AST nodes, getting rid of `type::effectiveType()`. No more static setters, we modify nodes directly now. However, when using typed nodes, we pass them around as `const`. When one needs to modify a node, that therefore usually involves a cast: `p.node.as<T>.setXYZ()`. In a few cases, it needs a `const_cast` of a typed reference. None more (public) setters returning `Node` references. New methods with names ending in `*Ref` return `NodeRef` instead. For more on the new structure and conventions, also see the Wiki: https://github.com/zeek/spicy/wiki/Notes-on-the-new-internal-HILTI-Spicy-AST-structure - Declarations now get globally unique "canonical IDs'. - Struct fields are now declarations. - Functions have a parent type that for methods will point to their struct/unit type. - `typeID()` and `cxxID()` moved up a level to become properties of `Type` (vs. being properties of the encapsulated specific type instantiations). - Using singletons for `type::Auto` and `type::Void`. - Remove "original nodes" and also most uses of "preserved nodes". - Remove AST-internal node caching. - AST dumps include node addresses to track identity. - We pass compiler `Unit`s around through `shared_ptr`, because they have a clear identity while being stored at various places.
- Loading branch information
Showing
408 changed files
with
11,788 additions
and
9,132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.3.0-dev.100 | ||
1.3.0-dev.101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
|
||
module hilti { | ||
|
||
public type BitOrder = enum { LSB0, MSB0 } &cxxname="hilti::rt::integer::BitOrder"; | ||
public type ByteOrder = enum { Little, Big, Network, Host } &cxxname="hilti::rt::ByteOrder"; | ||
public type Side = enum { Left, Right, Both } &cxxname="hilti::rt::bytes::Side"; | ||
public type AddressFamily = enum { IPv4, IPv6 } &cxxname="hilti::rt::AddressFamily"; | ||
public type RealType = enum { IEEE754_Single, IEEE754_Double } &cxxname="hilti::rt::real::Type"; | ||
public type Protocol = enum { TCP, UDP, ICMP } &cxxname="hilti::rt::Protocol"; | ||
public type Charset = enum { ASCII, UTF8} &cxxname="hilti::rt::bytes::Charset"; | ||
public type BitOrder = enum { LSB0, MSB0 } &cxxname="::hilti::rt::integer::BitOrder"; | ||
public type ByteOrder = enum { Little, Big, Network, Host } &cxxname="::hilti::rt::ByteOrder"; | ||
public type Side = enum { Left, Right, Both } &cxxname="::hilti::rt::bytes::Side"; | ||
public type AddressFamily = enum { IPv4, IPv6 } &cxxname="::hilti::rt::AddressFamily"; | ||
public type RealType = enum { IEEE754_Single, IEEE754_Double } &cxxname="::hilti::rt::real::Type"; | ||
public type Protocol = enum { TCP, UDP, ICMP } &cxxname="::hilti::rt::Protocol"; | ||
public type Charset = enum { ASCII, UTF8 } &cxxname="::hilti::rt::bytes::Charset"; | ||
public type Captures = vector<bytes>; | ||
|
||
public type MatchState = struct { | ||
method Captures captures(stream data); | ||
} &cxxname="hilti::rt::regexp::MatchState"; | ||
} &cxxname="::hilti::rt::regexp::MatchState"; | ||
|
||
declare public void print(any obj, bool newline = True) &cxxname="hilti::rt::print" &have_prototype; | ||
declare public void printValues(tuple<*> t, bool newline = True) &cxxname="hilti::rt::printValues" &have_prototype; | ||
declare public void print(any obj, bool newline = True) &cxxname="::hilti::rt::print" &have_prototype; | ||
declare public void printValues(tuple<*> t, bool newline = True) &cxxname="::hilti::rt::printValues" &have_prototype; | ||
|
||
declare public void debug(string dbg_stream, any obj) &cxxname="HILTI_RT_DEBUG" &have_prototype; | ||
declare public void debugIndent(string dbg_stream) &cxxname="hilti::rt::debug::indent" &have_prototype; | ||
declare public void debugDedent(string dbg_stream) &cxxname="hilti::rt::debug::dedent" &have_prototype; | ||
declare public void debugIndent(string dbg_stream) &cxxname="::hilti::rt::debug::indent" &have_prototype; | ||
declare public void debugDedent(string dbg_stream) &cxxname="::hilti::rt::debug::dedent" &have_prototype; | ||
|
||
declare public time current_time() &cxxname="hilti::rt::time::current_time" &have_prototype; | ||
declare public time mktime(uint<64> y, uint<64> m, uint<64> d, uint<64> H, uint<64> M, uint<64> S) &cxxname="hilti::rt::time::mktime" &have_prototype; | ||
declare public time current_time() &cxxname="::hilti::rt::time::current_time" &have_prototype; | ||
declare public time mktime(uint<64> y, uint<64> m, uint<64> d, uint<64> H, uint<64> M, uint<64> S) &cxxname="::hilti::rt::time::mktime" &have_prototype; | ||
|
||
declare public void abort() &cxxname="hilti::rt::abort_with_backtrace" &have_prototype; | ||
declare public void abort() &cxxname="::hilti::rt::abort_with_backtrace" &have_prototype; | ||
|
||
declare public string linker_scope() &cxxname="hilti::rt::linker_scope" &have_prototype; | ||
|
||
# Base type for all exceptions. | ||
public type Exception = exception &cxxname="hilti::rt::Exception"; | ||
public type Exception = exception &cxxname="::hilti::rt::Exception"; | ||
|
||
# Base type for all exception generated by the runtime system. Catching | ||
# this allows to continue after operations triggering runtime errors. | ||
public type RuntimeError = exception &cxxname="hilti::rt::RuntimeError"; | ||
public type RuntimeError = exception &cxxname="::hilti::rt::RuntimeError"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.