Commit Graph

8 Commits

Author SHA1 Message Date
Alex Hoppen
56a923475f [libSyntax] Reference count SyntaxData
Instead of having a heap-allocated RefCountedBox to store a SyntaxData's
parent, reference-count SyntaxData itself. This has a couple of
advantages:
 - When passing SyntaxData around, only a pointer needs to be passed
   instead of the entire struct contents. This is faster.
 - We can later introduce a SyntaxDataRef, which behaves similar to
   SyntaxData, but delegates the responsibility that the parent stays
   alive to the user. While sacrificing guaranteed memory safety, this
   means that SyntaxData can then be stack-allocated without any
   ref-counting overhead.
2021-03-03 08:48:24 +01:00
Alex Hoppen
a356c89e92 [libSyntax] Don't reference count SyntaxData
Instead, reference count the SyntaxData's parent. This has a couple of
advantages:
1. We eliminate a const_cast that was potentially unsafe
2. It more closely resembles the architecture on the Swift side
3. It has the potential to be optimised further if the parent can be
   accessed in an unsafe, non-reference-counted way
2021-01-29 13:08:12 +01:00
Rintaro Ishizaki
6108c881be [Syntax] Use TrailingObjects for SyntaxData (#14301)
This should optimize memory usage for SyntaxData.
2018-01-31 21:50:04 +09:00
Harlan
a5098e6b69 Generate libSyntax API (#10926)
* Generate libSyntax API

This patch removes the hand-rolled libSyntax API and replaces it with an
API that's entirely automatically generated. This means the API is
guaranteed to be internally stylistically and functionally consistent.
2017-07-25 18:19:58 -07:00
Harlan Haskins
2af1a77fad UnknownSyntax now accounts for non-token children. 2017-06-23 12:55:50 -07:00
Harlan Haskins
0e61e50ebb Fix UnknownSyntaxTests. One test still fails. 2017-06-23 11:59:16 -07:00
Harlan Haskins
972502d024 Remove subclasses of SyntaxData and move validation logic into Syntax subclasses. 2017-06-22 21:52:59 -07:00
David Farler
c958cd65eb [Syntax] Allow UnknownSyntax to have children
This will make it easier to incrementally implement syntax nodes,
while allowing us to embed nodes that we do know about inside ones
that we don't.

https://bugs.swift.org/browse/SR-4062
2017-02-28 14:30:57 -08:00