mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
//===--- UnknownSyntax.h - Swift Unknown Syntax Interface -------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SYNTAX_UNKNOWNSYNTAX_H
|
|
#define SWIFT_SYNTAX_UNKNOWNSYNTAX_H
|
|
|
|
#include "swift/Syntax/SyntaxData.h"
|
|
#include "swift/Syntax/Syntax.h"
|
|
|
|
namespace swift {
|
|
namespace syntax {
|
|
|
|
#pragma mark unknown-syntax API
|
|
|
|
/// A chunk of "unknown" syntax.
|
|
///
|
|
/// Effectively wraps a tree of RawSyntax.
|
|
///
|
|
/// This should not be vended by SyntaxFactory.
|
|
class UnknownSyntax : public Syntax {
|
|
void validate() const;
|
|
public:
|
|
UnknownSyntax(const RC<const SyntaxData> &Data) : Syntax(Data) {}
|
|
|
|
static bool classof(const Syntax *S) {
|
|
return S->isUnknown();
|
|
}
|
|
};
|
|
|
|
} // end namespace syntax
|
|
} // end namespace swift
|
|
|
|
#endif // SWIFT_SYNTAX_UNKNOWNSYNTAX_H
|