mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:30:12 +01:00
Use abbreviation "decl" instead of "declaration" (#3382)
Part of switching to the [abbreviations we've decided to use](https://docs.google.com/document/d/1RRYMm42osyqhI2LyjrjockYCutQ5dOf8Abu50kTrkX0/edit?resourcekey=0-kHyqOESbOHmzZphUbtLrTw#heading=h.pph7i5m5un7q). I will rename files in a follow-up PR.
This commit is contained in:
+2
-2
@@ -32,7 +32,7 @@ namespace Carbon::Internal {
|
||||
//
|
||||
// class MyKind : public CARBON_ENUM_BASE(MyKind) {
|
||||
// public:
|
||||
// #define CARBON_MY_KIND(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
// #define CARBON_MY_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
// #include ".../my_kind.def"
|
||||
//
|
||||
// // OPTIONAL: To support converting to and from the underlying type of
|
||||
@@ -205,7 +205,7 @@ class EnumBase : public Printable<DerivedT> {
|
||||
|
||||
// Use this within the Carbon enum class body to generate named constant
|
||||
// declarations for each value.
|
||||
#define CARBON_ENUM_CONSTANT_DECLARATION(Name) static const EnumType Name;
|
||||
#define CARBON_ENUM_CONSTANT_DECL(Name) static const EnumType Name;
|
||||
|
||||
// Use this immediately after the Carbon enum class body to define each named
|
||||
// constant.
|
||||
|
||||
@@ -19,7 +19,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(TestKind, uint8_t) {
|
||||
|
||||
class TestKind : public CARBON_ENUM_BASE(TestKind) {
|
||||
public:
|
||||
#define CARBON_ENUM_BASE_TEST_KIND(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
#define CARBON_ENUM_BASE_TEST_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
#include "common/enum_base_test.def"
|
||||
|
||||
using EnumBase::AsInt;
|
||||
|
||||
@@ -35,7 +35,7 @@ class AstRttiNodeKind : public CARBON_ENUM_BASE(AstRttiNodeKind) {
|
||||
// other enumerations to match, and to implement range checks.
|
||||
using EnumBase::AsInt;
|
||||
|
||||
CARBON_AST_FOR_EACH_FINAL_CLASS(CARBON_ENUM_CONSTANT_DECLARATION)
|
||||
CARBON_AST_FOR_EACH_FINAL_CLASS(CARBON_ENUM_CONSTANT_DECL)
|
||||
};
|
||||
|
||||
// Define the constant members for AstRttiNodeKind.
|
||||
|
||||
@@ -26,7 +26,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(Builtin, int) {
|
||||
|
||||
class Builtin : public CARBON_ENUM_BASE(Builtin) {
|
||||
public:
|
||||
#define CARBON_BUILTIN(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
#define CARBON_BUILTIN(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
#include "explorer/interpreter/builtins.def"
|
||||
|
||||
static const int NumBuiltins;
|
||||
|
||||
@@ -106,7 +106,7 @@ void LanguageServer::OnDocumentSymbol(
|
||||
for (const auto& node : parsed.postorder()) {
|
||||
clang::clangd::SymbolKind symbol_kind;
|
||||
switch (parsed.node_kind(node)) {
|
||||
case Parse::NodeKind::FunctionDeclaration:
|
||||
case Parse::NodeKind::FunctionDecl:
|
||||
case Parse::NodeKind::FunctionDefinitionStart:
|
||||
symbol_kind = clang::clangd::SymbolKind::Function;
|
||||
break;
|
||||
|
||||
+12
-14
@@ -32,7 +32,7 @@ Context::Context(const Lex::TokenizedBuffer& tokens, DiagnosticEmitter& emitter,
|
||||
inst_block_stack_("inst_block_stack_", sem_ir, vlog_stream),
|
||||
params_or_args_stack_("params_or_args_stack_", sem_ir, vlog_stream),
|
||||
args_type_info_stack_("args_type_info_stack_", sem_ir, vlog_stream),
|
||||
declaration_name_stack_(this) {
|
||||
decl_name_stack_(this) {
|
||||
// Inserts the "Error" and "Type" types as "used types" so that
|
||||
// canonicalization can skip them. We don't emit either for lowering.
|
||||
canonical_types_.insert({SemIR::InstId::BuiltinError, SemIR::TypeId::Error});
|
||||
@@ -78,13 +78,13 @@ auto Context::AddInstAndPush(Parse::Node parse_node, SemIR::Inst inst) -> void {
|
||||
|
||||
auto Context::DiagnoseDuplicateName(Parse::Node parse_node,
|
||||
SemIR::InstId prev_def_id) -> void {
|
||||
CARBON_DIAGNOSTIC(NameDeclarationDuplicate, Error,
|
||||
CARBON_DIAGNOSTIC(NameDeclDuplicate, Error,
|
||||
"Duplicate name being declared in the same scope.");
|
||||
CARBON_DIAGNOSTIC(NameDeclarationPrevious, Note,
|
||||
CARBON_DIAGNOSTIC(NameDeclPrevious, Note,
|
||||
"Name is previously declared here.");
|
||||
auto prev_def = insts().Get(prev_def_id);
|
||||
emitter_->Build(parse_node, NameDeclarationDuplicate)
|
||||
.Note(prev_def.parse_node(), NameDeclarationPrevious)
|
||||
emitter_->Build(parse_node, NameDeclDuplicate)
|
||||
.Note(prev_def.parse_node(), NameDeclPrevious)
|
||||
.Emit();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ auto Context::NoteIncompleteClass(SemIR::ClassId class_id,
|
||||
builder.Note(insts().Get(class_info.definition_id).parse_node(),
|
||||
ClassIncompleteWithinDefinition);
|
||||
} else {
|
||||
builder.Note(insts().Get(class_info.declaration_id).parse_node(),
|
||||
builder.Note(insts().Get(class_info.decl_id).parse_node(),
|
||||
ClassForwardDeclaredHere);
|
||||
}
|
||||
}
|
||||
@@ -128,10 +128,8 @@ auto Context::AddNameToLookup(Parse::Node name_node, SemIR::NameId name_id,
|
||||
}
|
||||
}
|
||||
|
||||
auto Context::LookupNameInDeclaration(Parse::Node parse_node,
|
||||
SemIR::NameId name_id,
|
||||
SemIR::NameScopeId scope_id)
|
||||
-> SemIR::InstId {
|
||||
auto Context::LookupNameInDecl(Parse::Node parse_node, SemIR::NameId name_id,
|
||||
SemIR::NameScopeId scope_id) -> SemIR::InstId {
|
||||
if (scope_id == SemIR::NameScopeId::Invalid) {
|
||||
// Look for a name in the current scope only. There are two cases where the
|
||||
// name would be in an outer scope:
|
||||
@@ -298,7 +296,7 @@ auto Context::GetConstantValue(SemIR::InstId inst_id) -> SemIR::InstId {
|
||||
break;
|
||||
|
||||
case SemIR::Field::Kind:
|
||||
case SemIR::FunctionDeclaration::Kind:
|
||||
case SemIR::FunctionDecl::Kind:
|
||||
return inst_id;
|
||||
|
||||
default:
|
||||
@@ -398,7 +396,7 @@ auto Context::AddCurrentCodeBlockToFunction(Parse::Node parse_node) -> void {
|
||||
|
||||
auto function_id =
|
||||
insts()
|
||||
.GetAs<SemIR::FunctionDeclaration>(return_scope_stack().back())
|
||||
.GetAs<SemIR::FunctionDecl>(return_scope_stack().back())
|
||||
.function_id;
|
||||
functions()
|
||||
.Get(function_id)
|
||||
@@ -785,13 +783,13 @@ class TypeCompleter {
|
||||
case SemIR::BranchIf::Kind:
|
||||
case SemIR::BranchWithArg::Kind:
|
||||
case SemIR::Call::Kind:
|
||||
case SemIR::ClassDeclaration::Kind:
|
||||
case SemIR::ClassDecl::Kind:
|
||||
case SemIR::ClassFieldAccess::Kind:
|
||||
case SemIR::ClassInit::Kind:
|
||||
case SemIR::Converted::Kind:
|
||||
case SemIR::Dereference::Kind:
|
||||
case SemIR::Field::Kind:
|
||||
case SemIR::FunctionDeclaration::Kind:
|
||||
case SemIR::FunctionDecl::Kind:
|
||||
case SemIR::InitializeFrom::Kind:
|
||||
case SemIR::IntegerLiteral::Kind:
|
||||
case SemIR::NameReference::Kind:
|
||||
|
||||
@@ -58,8 +58,8 @@ class Context {
|
||||
// Performs name lookup in a specified scope for a name appearing in a
|
||||
// declaration, returning the referenced instruction. If scope_id is invalid,
|
||||
// uses the current contextual scope.
|
||||
auto LookupNameInDeclaration(Parse::Node parse_node, SemIR::NameId name_id,
|
||||
SemIR::NameScopeId scope_id) -> SemIR::InstId;
|
||||
auto LookupNameInDecl(Parse::Node parse_node, SemIR::NameId name_id,
|
||||
SemIR::NameScopeId scope_id) -> SemIR::InstId;
|
||||
|
||||
// Performs an unqualified name lookup, returning the referenced instruction.
|
||||
auto LookupUnqualifiedName(Parse::Node parse_node, SemIR::NameId name_id)
|
||||
@@ -267,9 +267,7 @@ class Context {
|
||||
return break_continue_stack_;
|
||||
}
|
||||
|
||||
auto declaration_name_stack() -> DeclarationNameStack& {
|
||||
return declaration_name_stack_;
|
||||
}
|
||||
auto decl_name_stack() -> DeclNameStack& { return decl_name_stack_; }
|
||||
|
||||
// Directly expose SemIR::File data accessors for brevity in calls.
|
||||
auto identifiers() -> StringStoreWrapper<IdentifierId>& {
|
||||
@@ -324,8 +322,8 @@ class Context {
|
||||
|
||||
// The instruction associated with this entry, if any. This can be one of:
|
||||
//
|
||||
// - A `ClassDeclaration`, for a class definition scope.
|
||||
// - A `FunctionDeclaration`, for the outermost scope in a function
|
||||
// - A `ClassDecl`, for a class definition scope.
|
||||
// - A `FunctionDecl`, for the outermost scope in a function
|
||||
// definition.
|
||||
// - Invalid, for any other scope.
|
||||
SemIR::InstId scope_inst_id;
|
||||
@@ -408,7 +406,7 @@ class Context {
|
||||
InstBlockStack args_type_info_stack_;
|
||||
|
||||
// A stack of return scopes; i.e., targets for `return`. Inside a function,
|
||||
// this will be a FunctionDeclaration.
|
||||
// this will be a FunctionDecl.
|
||||
llvm::SmallVector<SemIR::InstId> return_scope_stack_;
|
||||
|
||||
// A stack of `break` and `continue` targets.
|
||||
@@ -426,7 +424,7 @@ class Context {
|
||||
ScopeIndex next_scope_index_ = ScopeIndex(0);
|
||||
|
||||
// The stack used for qualified declaration name construction.
|
||||
DeclarationNameStack declaration_name_stack_;
|
||||
DeclNameStack decl_name_stack_;
|
||||
|
||||
// Maps identifiers to name lookup results. Values are a stack of name lookup
|
||||
// results in the ancestor scopes. This offers constant-time lookup of names,
|
||||
|
||||
@@ -8,34 +8,32 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto DeclarationNameStack::MakeEmptyNameContext() -> NameContext {
|
||||
auto DeclNameStack::MakeEmptyNameContext() -> NameContext {
|
||||
return NameContext{.enclosing_scope = context_->current_scope_index(),
|
||||
.target_scope_id = context_->current_scope_id()};
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::MakeUnqualifiedName(Parse::Node parse_node,
|
||||
SemIR::NameId name_id)
|
||||
-> NameContext {
|
||||
auto DeclNameStack::MakeUnqualifiedName(Parse::Node parse_node,
|
||||
SemIR::NameId name_id) -> NameContext {
|
||||
NameContext context = MakeEmptyNameContext();
|
||||
ApplyNameQualifierTo(context, parse_node, name_id);
|
||||
return context;
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::PushScopeAndStartName() -> void {
|
||||
declaration_name_stack_.push_back(MakeEmptyNameContext());
|
||||
auto DeclNameStack::PushScopeAndStartName() -> void {
|
||||
decl_name_stack_.push_back(MakeEmptyNameContext());
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::FinishName() -> NameContext {
|
||||
CARBON_CHECK(declaration_name_stack_.back().state !=
|
||||
NameContext::State::Finished)
|
||||
auto DeclNameStack::FinishName() -> NameContext {
|
||||
CARBON_CHECK(decl_name_stack_.back().state != NameContext::State::Finished)
|
||||
<< "Finished name twice";
|
||||
if (context_->parse_tree().node_kind(
|
||||
context_->node_stack().PeekParseNode()) ==
|
||||
Parse::NodeKind::QualifiedDeclaration) {
|
||||
// Any parts from a QualifiedDeclaration will already have been processed
|
||||
Parse::NodeKind::QualifiedDecl) {
|
||||
// Any parts from a QualifiedDecl will already have been processed
|
||||
// into the name.
|
||||
context_->node_stack()
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::QualifiedDeclaration>();
|
||||
.PopAndDiscardSoloParseNode<Parse::NodeKind::QualifiedDecl>();
|
||||
} else {
|
||||
// The name had no qualifiers, so we need to process the node now.
|
||||
auto [parse_node, name_id] =
|
||||
@@ -43,22 +41,20 @@ auto DeclarationNameStack::FinishName() -> NameContext {
|
||||
ApplyNameQualifier(parse_node, name_id);
|
||||
}
|
||||
|
||||
NameContext result = declaration_name_stack_.back();
|
||||
declaration_name_stack_.back().state = NameContext::State::Finished;
|
||||
NameContext result = decl_name_stack_.back();
|
||||
decl_name_stack_.back().state = NameContext::State::Finished;
|
||||
return result;
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::PopScope() -> void {
|
||||
CARBON_CHECK(declaration_name_stack_.back().state ==
|
||||
NameContext::State::Finished)
|
||||
auto DeclNameStack::PopScope() -> void {
|
||||
CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Finished)
|
||||
<< "Missing call to FinishName before PopScope";
|
||||
context_->PopToScope(declaration_name_stack_.back().enclosing_scope);
|
||||
declaration_name_stack_.pop_back();
|
||||
context_->PopToScope(decl_name_stack_.back().enclosing_scope);
|
||||
decl_name_stack_.pop_back();
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::LookupOrAddName(NameContext name_context,
|
||||
SemIR::InstId target_id)
|
||||
-> SemIR::InstId {
|
||||
auto DeclNameStack::LookupOrAddName(NameContext name_context,
|
||||
SemIR::InstId target_id) -> SemIR::InstId {
|
||||
switch (name_context.state) {
|
||||
case NameContext::State::Error:
|
||||
// The name is invalid and a diagnostic has already been emitted.
|
||||
@@ -94,25 +90,25 @@ auto DeclarationNameStack::LookupOrAddName(NameContext name_context,
|
||||
}
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::AddNameToLookup(NameContext name_context,
|
||||
SemIR::InstId target_id) -> void {
|
||||
auto DeclNameStack::AddNameToLookup(NameContext name_context,
|
||||
SemIR::InstId target_id) -> void {
|
||||
auto existing_inst_id = LookupOrAddName(name_context, target_id);
|
||||
if (existing_inst_id.is_valid()) {
|
||||
context_->DiagnoseDuplicateName(name_context.parse_node, existing_inst_id);
|
||||
}
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::ApplyNameQualifier(Parse::Node parse_node,
|
||||
SemIR::NameId name_id) -> void {
|
||||
ApplyNameQualifierTo(declaration_name_stack_.back(), parse_node, name_id);
|
||||
auto DeclNameStack::ApplyNameQualifier(Parse::Node parse_node,
|
||||
SemIR::NameId name_id) -> void {
|
||||
ApplyNameQualifierTo(decl_name_stack_.back(), parse_node, name_id);
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::ApplyNameQualifierTo(NameContext& name_context,
|
||||
Parse::Node parse_node,
|
||||
SemIR::NameId name_id) -> void {
|
||||
auto DeclNameStack::ApplyNameQualifierTo(NameContext& name_context,
|
||||
Parse::Node parse_node,
|
||||
SemIR::NameId name_id) -> void {
|
||||
if (CanResolveQualifier(name_context, parse_node)) {
|
||||
// For identifier nodes, we need to perform a lookup on the identifier.
|
||||
auto resolved_inst_id = context_->LookupNameInDeclaration(
|
||||
auto resolved_inst_id = context_->LookupNameInDecl(
|
||||
name_context.parse_node, name_id, name_context.target_scope_id);
|
||||
if (!resolved_inst_id.is_valid()) {
|
||||
// Invalid indicates an unresolved name. Store it and return.
|
||||
@@ -129,15 +125,14 @@ auto DeclarationNameStack::ApplyNameQualifierTo(NameContext& name_context,
|
||||
}
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::UpdateScopeIfNeeded(NameContext& name_context)
|
||||
-> void {
|
||||
auto DeclNameStack::UpdateScopeIfNeeded(NameContext& name_context) -> void {
|
||||
// This will only be reached for resolved instructions. We update the target
|
||||
// scope based on the resolved type.
|
||||
auto resolved_inst = context_->insts().Get(name_context.resolved_inst_id);
|
||||
switch (resolved_inst.kind()) {
|
||||
case SemIR::ClassDeclaration::Kind: {
|
||||
case SemIR::ClassDecl::Kind: {
|
||||
const auto& class_info = context_->classes().Get(
|
||||
resolved_inst.As<SemIR::ClassDeclaration>().class_id);
|
||||
resolved_inst.As<SemIR::ClassDecl>().class_id);
|
||||
if (class_info.is_defined()) {
|
||||
name_context.state = NameContext::State::Resolved;
|
||||
name_context.target_scope_id = class_info.scope_id;
|
||||
@@ -160,8 +155,8 @@ auto DeclarationNameStack::UpdateScopeIfNeeded(NameContext& name_context)
|
||||
}
|
||||
}
|
||||
|
||||
auto DeclarationNameStack::CanResolveQualifier(NameContext& name_context,
|
||||
Parse::Node parse_node) -> bool {
|
||||
auto DeclNameStack::CanResolveQualifier(NameContext& name_context,
|
||||
Parse::Node parse_node) -> bool {
|
||||
switch (name_context.state) {
|
||||
case NameContext::State::Error:
|
||||
// Already in an error state, so return without examining.
|
||||
@@ -180,12 +175,12 @@ auto DeclarationNameStack::CanResolveQualifier(NameContext& name_context,
|
||||
// qualifier didn't resolve to a scoped entity.
|
||||
if (auto class_decl = context_->insts()
|
||||
.Get(name_context.resolved_inst_id)
|
||||
.TryAs<SemIR::ClassDeclaration>()) {
|
||||
CARBON_DIAGNOSTIC(QualifiedDeclarationInIncompleteClassScope, Error,
|
||||
.TryAs<SemIR::ClassDecl>()) {
|
||||
CARBON_DIAGNOSTIC(QualifiedDeclInIncompleteClassScope, Error,
|
||||
"Cannot declare a member of incomplete class `{0}`.",
|
||||
std::string);
|
||||
auto builder = context_->emitter().Build(
|
||||
name_context.parse_node, QualifiedDeclarationInIncompleteClassScope,
|
||||
name_context.parse_node, QualifiedDeclInIncompleteClassScope,
|
||||
context_->sem_ir().StringifyType(
|
||||
context_->classes().Get(class_decl->class_id).self_type_id,
|
||||
true));
|
||||
@@ -193,14 +188,14 @@ auto DeclarationNameStack::CanResolveQualifier(NameContext& name_context,
|
||||
builder.Emit();
|
||||
} else {
|
||||
CARBON_DIAGNOSTIC(
|
||||
QualifiedDeclarationInNonScope, Error,
|
||||
QualifiedDeclInNonScope, Error,
|
||||
"Declaration qualifiers are only allowed for entities "
|
||||
"that provide a scope.");
|
||||
CARBON_DIAGNOSTIC(QualifiedDeclarationNonScopeEntity, Note,
|
||||
CARBON_DIAGNOSTIC(QualifiedDeclNonScopeEntity, Note,
|
||||
"Non-scope entity referenced here.");
|
||||
context_->emitter()
|
||||
.Build(parse_node, QualifiedDeclarationInNonScope)
|
||||
.Note(name_context.parse_node, QualifiedDeclarationNonScopeEntity)
|
||||
.Build(parse_node, QualifiedDeclInNonScope)
|
||||
.Note(name_context.parse_node, QualifiedDeclNonScopeEntity)
|
||||
.Emit();
|
||||
}
|
||||
name_context.state = NameContext::State::Error;
|
||||
|
||||
@@ -74,7 +74,7 @@ class Context;
|
||||
// // is forward declared in `MyType`, but is not a scope itself.
|
||||
// fn MyNamespace.MyType.DoSomething() { ... }
|
||||
// ```
|
||||
class DeclarationNameStack {
|
||||
class DeclNameStack {
|
||||
public:
|
||||
// Context for declaration name construction.
|
||||
struct NameContext {
|
||||
@@ -128,7 +128,7 @@ class DeclarationNameStack {
|
||||
};
|
||||
};
|
||||
|
||||
explicit DeclarationNameStack(Context* context) : context_(context) {}
|
||||
explicit DeclNameStack(Context* context) : context_(context) {}
|
||||
|
||||
// Pushes processing of a new declaration name, which will be used
|
||||
// contextually, and prepares to enter scopes for that name. To pop this
|
||||
@@ -193,7 +193,7 @@ class DeclarationNameStack {
|
||||
Context* context_;
|
||||
|
||||
// Provides nesting for construction.
|
||||
llvm::SmallVector<NameContext> declaration_name_stack_;
|
||||
llvm::SmallVector<NameContext> decl_name_stack_;
|
||||
};
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
@@ -48,7 +48,7 @@ auto HandleCallExpr(Context& context, Parse::Node parse_node) -> bool {
|
||||
return diagnose_not_callable();
|
||||
}
|
||||
auto function_decl =
|
||||
context.insts().Get(function_decl_id).TryAs<SemIR::FunctionDeclaration>();
|
||||
context.insts().Get(function_decl_id).TryAs<SemIR::FunctionDecl>();
|
||||
if (!function_decl) {
|
||||
return diagnose_not_callable();
|
||||
}
|
||||
|
||||
@@ -14,29 +14,29 @@ auto HandleClassIntroducer(Context& context, Parse::Node parse_node) -> bool {
|
||||
// Push the bracketing node.
|
||||
context.node_stack().Push(parse_node);
|
||||
// A name should always follow.
|
||||
context.declaration_name_stack().PushScopeAndStartName();
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
|
||||
static auto BuildClassDeclaration(Context& context)
|
||||
static auto BuildClassDecl(Context& context)
|
||||
-> std::tuple<SemIR::ClassId, SemIR::InstId> {
|
||||
auto name_context = context.declaration_name_stack().FinishName();
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
auto class_keyword =
|
||||
context.node_stack()
|
||||
.PopForSoloParseNode<Parse::NodeKind::ClassIntroducer>();
|
||||
auto decl_block_id = context.inst_block_stack().Pop();
|
||||
|
||||
// Add the class declaration.
|
||||
auto class_decl = SemIR::ClassDeclaration{
|
||||
class_keyword, SemIR::ClassId::Invalid, decl_block_id};
|
||||
auto class_decl =
|
||||
SemIR::ClassDecl{class_keyword, SemIR::ClassId::Invalid, decl_block_id};
|
||||
auto class_decl_id = context.AddInst(class_decl);
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
auto existing_id = context.declaration_name_stack().LookupOrAddName(
|
||||
name_context, class_decl_id);
|
||||
auto existing_id =
|
||||
context.decl_name_stack().LookupOrAddName(name_context, class_decl_id);
|
||||
if (existing_id.is_valid()) {
|
||||
if (auto existing_class_decl =
|
||||
context.insts().Get(existing_id).TryAs<SemIR::ClassDeclaration>()) {
|
||||
context.insts().Get(existing_id).TryAs<SemIR::ClassDecl>()) {
|
||||
// This is a redeclaration of an existing class.
|
||||
class_decl.class_id = existing_class_decl->class_id;
|
||||
} else {
|
||||
@@ -51,13 +51,13 @@ static auto BuildClassDeclaration(Context& context)
|
||||
// was an error in the qualifier, we will have lost track of the class name
|
||||
// here. We should keep track of it even if the name is invalid.
|
||||
class_decl.class_id = context.classes().Add(
|
||||
{.name_id = name_context.state ==
|
||||
DeclarationNameStack::NameContext::State::Unresolved
|
||||
? name_context.unresolved_name_id
|
||||
: SemIR::NameId::Invalid,
|
||||
{.name_id =
|
||||
name_context.state == DeclNameStack::NameContext::State::Unresolved
|
||||
? name_context.unresolved_name_id
|
||||
: SemIR::NameId::Invalid,
|
||||
// `.self_type_id` depends on `class_id`, so is set below.
|
||||
.self_type_id = SemIR::TypeId::Invalid,
|
||||
.declaration_id = class_decl_id});
|
||||
.decl_id = class_decl_id});
|
||||
|
||||
// Build the `Self` type.
|
||||
auto& class_info = context.classes().Get(class_decl.class_id);
|
||||
@@ -67,22 +67,21 @@ static auto BuildClassDeclaration(Context& context)
|
||||
class_decl.class_id}));
|
||||
}
|
||||
|
||||
// Write the class ID into the ClassDeclaration.
|
||||
// Write the class ID into the ClassDecl.
|
||||
context.insts().Set(class_decl_id, class_decl);
|
||||
|
||||
return {class_decl.class_id, class_decl_id};
|
||||
}
|
||||
|
||||
auto HandleClassDeclaration(Context& context, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
BuildClassDeclaration(context);
|
||||
context.declaration_name_stack().PopScope();
|
||||
auto HandleClassDecl(Context& context, Parse::Node /*parse_node*/) -> bool {
|
||||
BuildClassDecl(context);
|
||||
context.decl_name_stack().PopScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleClassDefinitionStart(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
auto [class_id, class_decl_id] = BuildClassDeclaration(context);
|
||||
auto [class_id, class_decl_id] = BuildClassDecl(context);
|
||||
auto& class_info = context.classes().Get(class_id);
|
||||
|
||||
// Track that this declaration is the definition.
|
||||
@@ -133,7 +132,7 @@ auto HandleClassDefinition(Context& context, Parse::Node parse_node) -> bool {
|
||||
context.node_stack().Pop<Parse::NodeKind::ClassDefinitionStart>();
|
||||
context.inst_block_stack().Pop();
|
||||
context.PopScope();
|
||||
context.declaration_name_stack().PopScope();
|
||||
context.decl_name_stack().PopScope();
|
||||
|
||||
// The class type is now fully defined.
|
||||
auto& class_info = context.classes().Get(class_id);
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
// Build a FunctionDeclaration describing the signature of a function. This
|
||||
// Build a FunctionDecl describing the signature of a function. This
|
||||
// handles the common logic shared by function declaration syntax and function
|
||||
// definition syntax.
|
||||
static auto BuildFunctionDeclaration(Context& context, bool is_definition)
|
||||
static auto BuildFunctionDecl(Context& context, bool is_definition)
|
||||
-> std::pair<SemIR::FunctionId, SemIR::InstId> {
|
||||
// TODO: This contains the IR block for the parameters and return type. At
|
||||
// present, it's just loose, but it's not strictly required for parameter
|
||||
@@ -55,25 +55,23 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
|
||||
context.node_stack()
|
||||
.PopIf<Parse::NodeKind::ImplicitParameterList>()
|
||||
.value_or(SemIR::InstBlockId::Empty);
|
||||
auto name_context = context.declaration_name_stack().FinishName();
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
auto fn_node =
|
||||
context.node_stack()
|
||||
.PopForSoloParseNode<Parse::NodeKind::FunctionIntroducer>();
|
||||
|
||||
// Add the function declaration.
|
||||
auto function_decl = SemIR::FunctionDeclaration{
|
||||
auto function_decl = SemIR::FunctionDecl{
|
||||
fn_node, context.GetBuiltinType(SemIR::BuiltinKind::FunctionType),
|
||||
SemIR::FunctionId::Invalid};
|
||||
auto function_decl_id = context.AddInst(function_decl);
|
||||
|
||||
// Check whether this is a redeclaration.
|
||||
auto existing_id = context.declaration_name_stack().LookupOrAddName(
|
||||
name_context, function_decl_id);
|
||||
auto existing_id =
|
||||
context.decl_name_stack().LookupOrAddName(name_context, function_decl_id);
|
||||
if (existing_id.is_valid()) {
|
||||
if (auto existing_function_decl =
|
||||
context.insts()
|
||||
.Get(existing_id)
|
||||
.TryAs<SemIR::FunctionDeclaration>()) {
|
||||
context.insts().Get(existing_id).TryAs<SemIR::FunctionDecl>()) {
|
||||
// This is a redeclaration of an existing function.
|
||||
function_decl.function_id = existing_function_decl->function_id;
|
||||
|
||||
@@ -98,17 +96,17 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
|
||||
// Create a new function if this isn't a valid redeclaration.
|
||||
if (!function_decl.function_id.is_valid()) {
|
||||
function_decl.function_id = context.functions().Add(
|
||||
{.name_id = name_context.state ==
|
||||
DeclarationNameStack::NameContext::State::Unresolved
|
||||
? name_context.unresolved_name_id
|
||||
: SemIR::NameId::Invalid,
|
||||
{.name_id =
|
||||
name_context.state == DeclNameStack::NameContext::State::Unresolved
|
||||
? name_context.unresolved_name_id
|
||||
: SemIR::NameId::Invalid,
|
||||
.implicit_param_refs_id = implicit_param_refs_id,
|
||||
.param_refs_id = param_refs_id,
|
||||
.return_type_id = return_type_id,
|
||||
.return_slot_id = return_slot_id});
|
||||
}
|
||||
|
||||
// Write the function ID into the FunctionDeclaration.
|
||||
// Write the function ID into the FunctionDecl.
|
||||
context.insts().Set(function_decl_id, function_decl);
|
||||
|
||||
if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
|
||||
@@ -129,10 +127,9 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
|
||||
return {function_decl.function_id, function_decl_id};
|
||||
}
|
||||
|
||||
auto HandleFunctionDeclaration(Context& context, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
BuildFunctionDeclaration(context, /*is_definition=*/false);
|
||||
context.declaration_name_stack().PopScope();
|
||||
auto HandleFunctionDecl(Context& context, Parse::Node /*parse_node*/) -> bool {
|
||||
BuildFunctionDecl(context, /*is_definition=*/false);
|
||||
context.decl_name_stack().PopScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,7 +154,7 @@ auto HandleFunctionDefinition(Context& context, Parse::Node parse_node)
|
||||
context.PopScope();
|
||||
context.inst_block_stack().Pop();
|
||||
context.return_scope_stack().pop_back();
|
||||
context.declaration_name_stack().PopScope();
|
||||
context.decl_name_stack().PopScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -165,7 +162,7 @@ auto HandleFunctionDefinitionStart(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
// Process the declaration portion of the function.
|
||||
auto [function_id, decl_id] =
|
||||
BuildFunctionDeclaration(context, /*is_definition=*/true);
|
||||
BuildFunctionDecl(context, /*is_definition=*/true);
|
||||
auto& function = context.functions().Get(function_id);
|
||||
|
||||
// Track that this declaration is the definition.
|
||||
@@ -231,7 +228,7 @@ auto HandleFunctionIntroducer(Context& context, Parse::Node parse_node)
|
||||
// Push the bracketing node.
|
||||
context.node_stack().Push(parse_node);
|
||||
// A name should always follow.
|
||||
context.declaration_name_stack().PushScopeAndStartName();
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleInterfaceDeclaration(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
return context.TODO(parse_node, "HandleInterfaceDeclaration");
|
||||
auto HandleInterfaceDecl(Context& context, Parse::Node parse_node) -> bool {
|
||||
return context.TODO(parse_node, "HandleInterfaceDecl");
|
||||
}
|
||||
|
||||
auto HandleInterfaceDefinition(Context& context, Parse::Node parse_node)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleLetDeclaration(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto HandleLetDecl(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto value_id = context.node_stack().PopExpr();
|
||||
SemIR::InstId pattern_id =
|
||||
context.node_stack().Pop<Parse::NodeKind::PatternBinding>();
|
||||
|
||||
@@ -43,7 +43,7 @@ static auto GetExprValueForLookupResult(Context& context,
|
||||
-> SemIR::InstId {
|
||||
// If lookup finds a class declaration, the value is its `Self` type.
|
||||
auto lookup_result = context.insts().Get(lookup_result_id);
|
||||
if (auto class_decl = lookup_result.TryAs<SemIR::ClassDeclaration>()) {
|
||||
if (auto class_decl = lookup_result.TryAs<SemIR::ClassDecl>()) {
|
||||
return context.sem_ir().GetTypeAllowBuiltinTypes(
|
||||
context.classes().Get(class_decl->class_id).self_type_id);
|
||||
}
|
||||
@@ -148,9 +148,8 @@ auto HandleMemberAccessExpr(Context& context, Parse::Node parse_node) -> bool {
|
||||
CARBON_CHECK(function_name_id.is_valid())
|
||||
<< "Non-constant value " << context.insts().Get(member_id)
|
||||
<< " of function type";
|
||||
auto function_decl = context.insts()
|
||||
.Get(function_name_id)
|
||||
.TryAs<SemIR::FunctionDeclaration>();
|
||||
auto function_decl =
|
||||
context.insts().Get(function_name_id).TryAs<SemIR::FunctionDecl>();
|
||||
CARBON_CHECK(function_decl)
|
||||
<< "Unexpected value " << context.insts().Get(function_name_id)
|
||||
<< " of function type";
|
||||
@@ -242,25 +241,24 @@ auto HandleNameExpr(Context& context, Parse::Node parse_node) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleQualifiedDeclaration(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
auto HandleQualifiedDecl(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto [parse_node2, name_id2] =
|
||||
context.node_stack().PopWithParseNode<Parse::NodeKind::Name>();
|
||||
|
||||
Parse::Node parse_node1 = context.node_stack().PeekParseNode();
|
||||
switch (context.parse_tree().node_kind(parse_node1)) {
|
||||
case Parse::NodeKind::QualifiedDeclaration:
|
||||
// This is the second or subsequent QualifiedDeclaration in a chain.
|
||||
// Nothing to do: the first QualifiedDeclaration remains as a
|
||||
// bracketing node for later QualifiedDeclarations.
|
||||
case Parse::NodeKind::QualifiedDecl:
|
||||
// This is the second or subsequent QualifiedDecl in a chain.
|
||||
// Nothing to do: the first QualifiedDecl remains as a
|
||||
// bracketing node for later QualifiedDecls.
|
||||
break;
|
||||
|
||||
case Parse::NodeKind::Name: {
|
||||
// This is the first QualifiedDeclaration in a chain, and starts with a
|
||||
// This is the first QualifiedDecl in a chain, and starts with a
|
||||
// name.
|
||||
auto name_id = context.node_stack().Pop<Parse::NodeKind::Name>();
|
||||
context.declaration_name_stack().ApplyNameQualifier(parse_node1, name_id);
|
||||
// Add the QualifiedDeclaration so that it can be used for bracketing.
|
||||
context.decl_name_stack().ApplyNameQualifier(parse_node1, name_id);
|
||||
// Add the QualifiedDecl so that it can be used for bracketing.
|
||||
context.node_stack().Push(parse_node);
|
||||
break;
|
||||
}
|
||||
@@ -270,7 +268,7 @@ auto HandleQualifiedDeclaration(Context& context, Parse::Node parse_node)
|
||||
"declaration name";
|
||||
}
|
||||
|
||||
context.declaration_name_stack().ApplyNameQualifier(parse_node2, name_id2);
|
||||
context.decl_name_stack().ApplyNameQualifier(parse_node2, name_id2);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleNamedConstraintDeclaration(Context& context, Parse::Node parse_node)
|
||||
auto HandleNamedConstraintDecl(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
return context.TODO(parse_node, "HandleNamedConstraintDeclaration");
|
||||
return context.TODO(parse_node, "HandleNamedConstraintDecl");
|
||||
}
|
||||
|
||||
auto HandleNamedConstraintDefinition(Context& context, Parse::Node parse_node)
|
||||
|
||||
@@ -9,17 +9,17 @@ namespace Carbon::Check {
|
||||
|
||||
auto HandleNamespaceStart(Context& context, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
context.declaration_name_stack().PushScopeAndStartName();
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleNamespace(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto name_context = context.declaration_name_stack().FinishName();
|
||||
auto name_context = context.decl_name_stack().FinishName();
|
||||
auto namespace_id = context.AddInst(SemIR::Namespace{
|
||||
parse_node, context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
|
||||
context.name_scopes().Add()});
|
||||
context.declaration_name_stack().AddNameToLookup(name_context, namespace_id);
|
||||
context.declaration_name_stack().PopScope();
|
||||
context.decl_name_stack().AddNameToLookup(name_context, namespace_id);
|
||||
context.decl_name_stack().PopScope();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleEmptyDeclaration(Context& /*context*/, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
auto HandleEmptyDecl(Context& /*context*/, Parse::Node /*parse_node*/) -> bool {
|
||||
// Empty declarations have no actions associated.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,14 +64,13 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
|
||||
context.node_stack().PeekParseNode())) {
|
||||
case Parse::NodeKind::VariableIntroducer: {
|
||||
// A `var` declaration at class scope introduces a field.
|
||||
auto enclosing_class_decl =
|
||||
context.GetCurrentScopeAs<SemIR::ClassDeclaration>();
|
||||
auto enclosing_class_decl = context.GetCurrentScopeAs<SemIR::ClassDecl>();
|
||||
if (!context.TryToCompleteType(cast_type_id, [&] {
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInVarDeclaration, Error,
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInVarDecl, Error,
|
||||
"{0} has incomplete type `{1}`.", llvm::StringRef,
|
||||
std::string);
|
||||
return context.emitter().Build(
|
||||
type_node_copy, IncompleteTypeInVarDeclaration,
|
||||
type_node_copy, IncompleteTypeInVarDecl,
|
||||
enclosing_class_decl ? "Field" : "Variable",
|
||||
context.sem_ir().StringifyType(cast_type_id, true));
|
||||
})) {
|
||||
@@ -116,11 +115,11 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
|
||||
|
||||
case Parse::NodeKind::LetIntroducer:
|
||||
if (!context.TryToCompleteType(cast_type_id, [&] {
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInLetDeclaration, Error,
|
||||
CARBON_DIAGNOSTIC(IncompleteTypeInLetDecl, Error,
|
||||
"`let` binding has incomplete type `{0}`.",
|
||||
std::string);
|
||||
return context.emitter().Build(
|
||||
type_node_copy, IncompleteTypeInLetDeclaration,
|
||||
type_node_copy, IncompleteTypeInLetDecl,
|
||||
context.sem_ir().StringifyType(cast_type_id, true));
|
||||
})) {
|
||||
cast_type_id = SemIR::TypeId::Error;
|
||||
|
||||
@@ -28,7 +28,7 @@ auto HandleExprStatement(Context& context, Parse::Node /*parse_node*/) -> bool {
|
||||
|
||||
auto HandleReturnStatement(Context& context, Parse::Node parse_node) -> bool {
|
||||
CARBON_CHECK(!context.return_scope_stack().empty());
|
||||
auto fn_inst = context.insts().GetAs<SemIR::FunctionDeclaration>(
|
||||
auto fn_inst = context.insts().GetAs<SemIR::FunctionDecl>(
|
||||
context.return_scope_stack().back());
|
||||
const auto& callable = context.functions().Get(fn_inst.function_id);
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleVariableDeclaration(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
auto HandleVariableDecl(Context& context, Parse::Node parse_node) -> bool {
|
||||
// Handle the optional initializer.
|
||||
auto init_id = SemIR::InstId::Invalid;
|
||||
bool has_init =
|
||||
@@ -26,9 +25,9 @@ auto HandleVariableDeclaration(Context& context, Parse::Node parse_node)
|
||||
if (auto bind_name = context.insts().Get(value_id).TryAs<SemIR::BindName>()) {
|
||||
// Form a corresponding name in the current context, and bind the name to
|
||||
// the variable.
|
||||
context.declaration_name_stack().AddNameToLookup(
|
||||
context.declaration_name_stack().MakeUnqualifiedName(
|
||||
bind_name->parse_node, bind_name->name_id),
|
||||
context.decl_name_stack().AddNameToLookup(
|
||||
context.decl_name_stack().MakeUnqualifiedName(bind_name->parse_node,
|
||||
bind_name->name_id),
|
||||
value_id);
|
||||
value_id = bind_name->value_id;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ class NodeStack {
|
||||
case Parse::NodeKind::LetIntroducer:
|
||||
case Parse::NodeKind::ParameterListStart:
|
||||
case Parse::NodeKind::ParenExprOrTupleLiteralStart:
|
||||
case Parse::NodeKind::QualifiedDeclaration:
|
||||
case Parse::NodeKind::QualifiedDecl:
|
||||
case Parse::NodeKind::ReturnStatementStart:
|
||||
case Parse::NodeKind::SelfValueName:
|
||||
case Parse::NodeKind::StructLiteralOrStructTypeLiteralStart:
|
||||
|
||||
@@ -24,7 +24,7 @@ var p: Incomplete* = &a[0];
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_incomplete_element.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Incomplete, ()
|
||||
// CHECK:STDOUT: class_decl @Incomplete, ()
|
||||
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete
|
||||
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_reference Incomplete, %Incomplete
|
||||
// CHECK:STDOUT: %.loc15_21: i32 = int_literal 1
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ fn Initializing() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "identity.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @X, ()
|
||||
// CHECK:STDOUT: class_decl @X, ()
|
||||
// CHECK:STDOUT: %X: type = class_type @X
|
||||
// CHECK:STDOUT: %Value: <function> = fn_decl @Value
|
||||
// CHECK:STDOUT: %Reference: <function> = fn_decl @Reference
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ fn Var() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "tuple.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @X, ()
|
||||
// CHECK:STDOUT: class_decl @X, ()
|
||||
// CHECK:STDOUT: %X: type = class_type @X
|
||||
// CHECK:STDOUT: %Make: <function> = fn_decl @Make
|
||||
// CHECK:STDOUT: %Let: <function> = fn_decl @Let
|
||||
|
||||
@@ -25,7 +25,7 @@ fn B() {}
|
||||
// CHECK:STDOUT: type0: {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
|
||||
// CHECK:STDOUT: type_blocks: {}
|
||||
// CHECK:STDOUT: insts:
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDeclaration, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDecl, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+1: {kind: Return}
|
||||
// CHECK:STDOUT: inst_blocks:
|
||||
// CHECK:STDOUT: block0: {}
|
||||
@@ -54,7 +54,7 @@ fn B() {}
|
||||
// CHECK:STDOUT: type0: {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
|
||||
// CHECK:STDOUT: type_blocks: {}
|
||||
// CHECK:STDOUT: insts:
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDeclaration, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDecl, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+1: {kind: Return}
|
||||
// CHECK:STDOUT: inst_blocks:
|
||||
// CHECK:STDOUT: block0: {}
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ fn B() {}
|
||||
// CHECK:STDOUT: type0: {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
|
||||
// CHECK:STDOUT: type_blocks: {}
|
||||
// CHECK:STDOUT: insts:
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDeclaration, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDecl, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+1: {kind: Return}
|
||||
// CHECK:STDOUT: inst_blocks:
|
||||
// CHECK:STDOUT: block0: {}
|
||||
@@ -45,7 +45,7 @@ fn B() {}
|
||||
// CHECK:STDOUT: type0: {inst: instFunctionType, value_rep: {kind: copy, type: type0}}
|
||||
// CHECK:STDOUT: type_blocks: {}
|
||||
// CHECK:STDOUT: insts:
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDeclaration, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+0: {kind: FunctionDecl, arg0: function0, type: type0}
|
||||
// CHECK:STDOUT: inst+1: {kind: Return}
|
||||
// CHECK:STDOUT: inst_blocks:
|
||||
// CHECK:STDOUT: block0: {}
|
||||
|
||||
@@ -41,7 +41,7 @@ fn Foo(n: i32) -> (i32, f64) {
|
||||
// CHECK:STDOUT: inst+4: {kind: Converted, arg0: inst+2, arg1: inst+3, type: typeTypeType}
|
||||
// CHECK:STDOUT: inst+5: {kind: VarStorage, arg0: nameReturnSlot, type: type3}
|
||||
// CHECK:STDOUT: inst+6: {kind: PointerType, arg0: type3, type: typeTypeType}
|
||||
// CHECK:STDOUT: inst+7: {kind: FunctionDeclaration, arg0: function0, type: type5}
|
||||
// CHECK:STDOUT: inst+7: {kind: FunctionDecl, arg0: function0, type: type5}
|
||||
// CHECK:STDOUT: inst+8: {kind: NameReference, arg0: name1, arg1: inst+0, type: type0}
|
||||
// CHECK:STDOUT: inst+9: {kind: IntegerLiteral, arg0: int3, type: type0}
|
||||
// CHECK:STDOUT: inst+10: {kind: BinaryOperatorAdd, arg0: inst+8, arg1: inst+9, type: type0}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ fn Foo(n: i32) -> (i32, f64) {
|
||||
// CHECK:STDOUT: inst+4: {kind: Converted, arg0: inst+2, arg1: inst+3, type: typeTypeType}
|
||||
// CHECK:STDOUT: inst+5: {kind: VarStorage, arg0: nameReturnSlot, type: type3}
|
||||
// CHECK:STDOUT: inst+6: {kind: PointerType, arg0: type3, type: typeTypeType}
|
||||
// CHECK:STDOUT: inst+7: {kind: FunctionDeclaration, arg0: function0, type: type5}
|
||||
// CHECK:STDOUT: inst+7: {kind: FunctionDecl, arg0: function0, type: type5}
|
||||
// CHECK:STDOUT: inst+8: {kind: NameReference, arg0: name1, arg1: inst+0, type: type0}
|
||||
// CHECK:STDOUT: inst+9: {kind: IntegerLiteral, arg0: int3, type: type0}
|
||||
// CHECK:STDOUT: inst+10: {kind: BinaryOperatorAdd, arg0: inst+8, arg1: inst+9, type: type0}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
// NOAUTOUPDATE
|
||||
// SET-CHECK-SUBSET
|
||||
// CHECK:STDERR: Node Push 0: FunctionIntroducer -> <none>
|
||||
// CHECK:STDERR: AddInst: {kind: FunctionDeclaration, arg0: {{.*}}, type: type{{[0-9]+}}}
|
||||
// CHECK:STDERR: AddInst: {kind: FunctionDecl, arg0: {{.*}}, type: type{{[0-9]+}}}
|
||||
// CHECK:STDERR: inst_block_stack_ Push 1
|
||||
// CHECK:STDERR: AddInst: {kind: Return}
|
||||
// CHECK:STDERR: inst_block_stack_ Pop 1: block{{[0-9]+}}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ fn Run() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "basic.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: %Run: <function> = fn_decl @Run
|
||||
|
||||
@@ -21,7 +21,7 @@ class Class {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_addr_not_self.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ fn F(c: Class, p: Class*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_addr_self.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F.2
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ fn CallReturnIncomplete() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_incomplete.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %.loc15: <function> = fn_decl @.1
|
||||
// CHECK:STDOUT: %CallClassFunction: <function> = fn_decl @CallClassFunction
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ fn F() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_init.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -29,7 +29,7 @@ fn F() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_init_as_inplace.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
|
||||
@@ -43,9 +43,9 @@ fn F(s: {.a: A}, b: B) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_memaccess_category.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @A, ()
|
||||
// CHECK:STDOUT: class_decl @A, ()
|
||||
// CHECK:STDOUT: %A: type = class_type @A
|
||||
// CHECK:STDOUT: class_declaration @B, ()
|
||||
// CHECK:STDOUT: class_decl @B, ()
|
||||
// CHECK:STDOUT: %B: type = class_type @B
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F.2
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -26,7 +26,7 @@ fn T.F() {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_member_of_let.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %Class.ref: type = name_reference Class, %Class
|
||||
// CHECK:STDOUT: %T: type = bind_name T, %Class.ref
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ fn F(c: Class) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_method.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -26,17 +26,17 @@ class Y {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_redeclaration_scope.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @A.1, ()
|
||||
// CHECK:STDOUT: class_decl @A.1, ()
|
||||
// CHECK:STDOUT: %A: type = class_type @A.1
|
||||
// CHECK:STDOUT: class_declaration @X, ()
|
||||
// CHECK:STDOUT: class_decl @X, ()
|
||||
// CHECK:STDOUT: %X: type = class_type @X
|
||||
// CHECK:STDOUT: class_declaration @A.1, ()
|
||||
// CHECK:STDOUT: class_declaration @Y, ()
|
||||
// CHECK:STDOUT: class_decl @A.1, ()
|
||||
// CHECK:STDOUT: class_decl @Y, ()
|
||||
// CHECK:STDOUT: %Y: type = class_type @Y
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @A.1 {
|
||||
// CHECK:STDOUT: class_declaration @B.2, ()
|
||||
// CHECK:STDOUT: class_decl @B.2, ()
|
||||
// CHECK:STDOUT: %B: type = class_type @B.2
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
@@ -44,16 +44,16 @@ class Y {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @X {
|
||||
// CHECK:STDOUT: class_declaration @A.2, ()
|
||||
// CHECK:STDOUT: class_decl @A.2, ()
|
||||
// CHECK:STDOUT: %A: type = class_type @A.2
|
||||
// CHECK:STDOUT: class_declaration @B.1, ()
|
||||
// CHECK:STDOUT: class_decl @B.1, ()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .A = <unexpected instref inst+4>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @A.2 {
|
||||
// CHECK:STDOUT: class_declaration @B.1, ()
|
||||
// CHECK:STDOUT: class_decl @B.1, ()
|
||||
// CHECK:STDOUT: %B: type = class_type @B.1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
@@ -68,7 +68,7 @@ class Y {
|
||||
// CHECK:STDOUT: class @B.2;
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Y {
|
||||
// CHECK:STDOUT: class_declaration @.1, ()
|
||||
// CHECK:STDOUT: class_decl @.1, ()
|
||||
// CHECK:STDOUT: %.loc21: type = class_type @.1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
|
||||
+2
-2
@@ -29,9 +29,9 @@ fn Class.H() {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_redefinition.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: %H: <function> = fn_decl @H
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class Class {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_reorder.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_scope.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+2
-2
@@ -57,11 +57,11 @@ fn CallWrongSelf(ws: WrongSelf) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_self.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F.1
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: class_declaration @WrongSelf, ()
|
||||
// CHECK:STDOUT: class_decl @WrongSelf, ()
|
||||
// CHECK:STDOUT: %WrongSelf: type = class_type @WrongSelf
|
||||
// CHECK:STDOUT: %CallWrongSelf: <function> = fn_decl @CallWrongSelf
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -26,7 +26,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_unbound_field.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -22,7 +22,7 @@ fn G(c: Class) -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_unknown_member.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ fn Run() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "field_access.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %Run: <function> = fn_decl @Run
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -23,7 +23,7 @@ fn Run() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "field_access_in_value.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %Run: <function> = fn_decl @Run
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class Class;
|
||||
fn F(p: Class*) -> Class* { return p; }
|
||||
|
||||
// CHECK:STDOUT: file "forward_declared.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ fn MakeReorder(n: i32, next: Class*) -> Class {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "init.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %Make: <function> = fn_decl @Make
|
||||
// CHECK:STDOUT: %MakeReorder: <function> = fn_decl @MakeReorder
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "init_as.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+2
-2
@@ -30,10 +30,10 @@ fn MakeOuter() -> Outer {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "init_nested.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Inner, ()
|
||||
// CHECK:STDOUT: class_decl @Inner, ()
|
||||
// CHECK:STDOUT: %Inner: type = class_type @Inner
|
||||
// CHECK:STDOUT: %MakeInner: <function> = fn_decl @MakeInner
|
||||
// CHECK:STDOUT: class_declaration @Outer, ()
|
||||
// CHECK:STDOUT: class_decl @Outer, ()
|
||||
// CHECK:STDOUT: %Outer: type = class_type @Outer
|
||||
// CHECK:STDOUT: %MakeOuter: <function> = fn_decl @MakeOuter
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ fn CallGOnInitializingExpr() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "method.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: %Call: <function> = fn_decl @Call
|
||||
|
||||
+2
-2
@@ -36,13 +36,13 @@ fn F(a: Outer*) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "nested.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Outer, ()
|
||||
// CHECK:STDOUT: class_decl @Outer, ()
|
||||
// CHECK:STDOUT: %Outer: type = class_type @Outer
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Outer {
|
||||
// CHECK:STDOUT: class_declaration @Inner, ()
|
||||
// CHECK:STDOUT: class_decl @Inner, ()
|
||||
// CHECK:STDOUT: %Inner: type = class_type @Inner
|
||||
// CHECK:STDOUT: %Self.ref: type = name_reference Self, file.%Outer
|
||||
// CHECK:STDOUT: %.loc14_15: type = ptr_type Outer
|
||||
|
||||
+2
-2
@@ -27,14 +27,14 @@ fn G(o: Outer) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "nested_name.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Outer, ()
|
||||
// CHECK:STDOUT: class_decl @Outer, ()
|
||||
// CHECK:STDOUT: %Outer: type = class_type @Outer
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Outer {
|
||||
// CHECK:STDOUT: class_declaration @Inner, ()
|
||||
// CHECK:STDOUT: class_decl @Inner, ()
|
||||
// CHECK:STDOUT: %Inner: type = class_type @Inner
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@ fn Class.F() {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "redeclaration.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ fn Class.F() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "reenter_scope.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ fn Run() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "scope.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F.2
|
||||
// CHECK:STDOUT: %Run: <function> = fn_decl @Run
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ fn Class.G[addr self: Class*]() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "self.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ fn Class.F[self: Class]() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "self_type.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ fn Run() -> i32 {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "static_method.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Class, ()
|
||||
// CHECK:STDOUT: class_decl @Class, ()
|
||||
// CHECK:STDOUT: %Class: type = class_type @Class
|
||||
// CHECK:STDOUT: %Run: <function> = fn_decl @Run
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -40,7 +40,7 @@ class C {
|
||||
// CHECK:STDOUT: file "fail_not_in_function.carbon" {
|
||||
// CHECK:STDOUT: %.loc17: i32 = block_arg <unexpected instblockref block4>
|
||||
// CHECK:STDOUT: %x: i32 = bind_name x, %.loc17
|
||||
// CHECK:STDOUT: class_declaration @C, ()
|
||||
// CHECK:STDOUT: class_decl @C, ()
|
||||
// CHECK:STDOUT: %C: type = class_type @C
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -24,7 +24,7 @@ var p: Incomplete* = &s.a;
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_nested_incomplete.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Incomplete, ()
|
||||
// CHECK:STDOUT: class_decl @Incomplete, ()
|
||||
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete
|
||||
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_reference Incomplete, %Incomplete
|
||||
// CHECK:STDOUT: %.loc15: type = struct_type {.a: Incomplete}
|
||||
|
||||
@@ -26,7 +26,7 @@ var p: Incomplete* = &t[1];
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_nested_incomplete.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @Incomplete, ()
|
||||
// CHECK:STDOUT: class_decl @Incomplete, ()
|
||||
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete
|
||||
// CHECK:STDOUT: %Incomplete.ref.loc15: type = name_reference Incomplete, %Incomplete
|
||||
// CHECK:STDOUT: %.loc15_24.1: (type, type) = tuple_literal (i32, %Incomplete.ref.loc15)
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ fn F(x: X) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file "fail_not_copyable.carbon" {
|
||||
// CHECK:STDOUT: class_declaration @X, ()
|
||||
// CHECK:STDOUT: class_decl @X, ()
|
||||
// CHECK:STDOUT: %X: type = class_type @X
|
||||
// CHECK:STDOUT: %F: <function> = fn_decl @F
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -70,7 +70,7 @@ CARBON_DIAGNOSTIC_KIND(ExpectedParenAfter)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedExprSemi)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedStatementSemi)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedStructLiteralField)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedVariableDeclaration)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedVariableDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedVariableName)
|
||||
CARBON_DIAGNOSTIC_KIND(OperatorRequiresParentheses)
|
||||
CARBON_DIAGNOSTIC_KIND(StatementOperatorAsSubexpr)
|
||||
@@ -78,10 +78,10 @@ CARBON_DIAGNOSTIC_KIND(UnaryOperatorRequiresParentheses)
|
||||
CARBON_DIAGNOSTIC_KIND(UnaryOperatorHasWhitespace)
|
||||
CARBON_DIAGNOSTIC_KIND(UnaryOperatorRequiresWhitespace)
|
||||
CARBON_DIAGNOSTIC_KIND(UnexpectedTokenAfterListElement)
|
||||
CARBON_DIAGNOSTIC_KIND(UnrecognizedDeclaration)
|
||||
CARBON_DIAGNOSTIC_KIND(UnrecognizedDecl)
|
||||
|
||||
// Package-related diagnostics.
|
||||
CARBON_DIAGNOSTIC_KIND(FirstDeclaration)
|
||||
CARBON_DIAGNOSTIC_KIND(FirstDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(FirstNonCommentLine)
|
||||
CARBON_DIAGNOSTIC_KIND(PackageTooLate)
|
||||
CARBON_DIAGNOSTIC_KIND(ImportTooLate)
|
||||
@@ -99,9 +99,9 @@ CARBON_DIAGNOSTIC_KIND(ExpectedThenAfterIf)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedElseAfterIf)
|
||||
|
||||
// Declaration diagnostics.
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclarationName)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclarationSemi)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclarationSemiOrDefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclName)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclSemi)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedDeclSemiOrDefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(ExpectedInitializerAfterLet)
|
||||
CARBON_DIAGNOSTIC_KIND(MethodImplNotAllowed)
|
||||
CARBON_DIAGNOSTIC_KIND(ParametersRequiredAfterImplicit)
|
||||
@@ -140,18 +140,18 @@ CARBON_DIAGNOSTIC_KIND(DereferenceOfType)
|
||||
CARBON_DIAGNOSTIC_KIND(FunctionPreviousDefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(FunctionRedefinition)
|
||||
CARBON_DIAGNOSTIC_KIND(NameNotFound)
|
||||
CARBON_DIAGNOSTIC_KIND(NameDeclarationDuplicate)
|
||||
CARBON_DIAGNOSTIC_KIND(NameDeclarationPrevious)
|
||||
CARBON_DIAGNOSTIC_KIND(NameDeclDuplicate)
|
||||
CARBON_DIAGNOSTIC_KIND(NameDeclPrevious)
|
||||
CARBON_DIAGNOSTIC_KIND(MissingReturnStatement)
|
||||
CARBON_DIAGNOSTIC_KIND(RepeatedConst)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInConversion)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInFunctionParam)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInFunctionReturnType)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInInitialization)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInLetDeclaration)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInLetDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInMemberAccess)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInValueConversion)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInVarDeclaration)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInVarDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(InvalidArrayExpr)
|
||||
CARBON_DIAGNOSTIC_KIND(TypeNotIndexable)
|
||||
CARBON_DIAGNOSTIC_KIND(IndexOutOfBounds)
|
||||
@@ -168,9 +168,9 @@ CARBON_DIAGNOSTIC_KIND(ReturnStatementMissingExpr)
|
||||
CARBON_DIAGNOSTIC_KIND(ImplicitAsConversionFailure)
|
||||
CARBON_DIAGNOSTIC_KIND(ExplicitAsConversionFailure)
|
||||
CARBON_DIAGNOSTIC_KIND(TypeExprEvaluationFailure)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclarationInIncompleteClassScope)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclarationInNonScope)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclarationNonScopeEntity)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclInIncompleteClassScope)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclInNonScope)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedDeclNonScopeEntity)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedExprInIncompleteClassScope)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedExprUnsupported)
|
||||
CARBON_DIAGNOSTIC_KIND(QualifiedExprNameNotFound)
|
||||
|
||||
@@ -29,7 +29,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(DiagnosticKind, uint16_t) {
|
||||
// to the consuming code.
|
||||
class DiagnosticKind : public CARBON_ENUM_BASE(DiagnosticKind) {
|
||||
public:
|
||||
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
#define CARBON_DIAGNOSTIC_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
#include "toolchain/diagnostics/diagnostic_kind.def"
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(TokenKind, uint8_t) {
|
||||
|
||||
class TokenKind : public CARBON_ENUM_BASE(TokenKind) {
|
||||
public:
|
||||
#define CARBON_TOKEN(TokenName) CARBON_ENUM_CONSTANT_DECLARATION(TokenName)
|
||||
#define CARBON_TOKEN(TokenName) CARBON_ENUM_CONSTANT_DECL(TokenName)
|
||||
#include "toolchain/lex/token_kind.def"
|
||||
|
||||
// An array of all the keyword tokens.
|
||||
|
||||
@@ -41,7 +41,7 @@ auto FileContext::Run() -> std::unique_ptr<llvm::Module> {
|
||||
// Lower function declarations.
|
||||
functions_.resize_for_overwrite(sem_ir_->functions().size());
|
||||
for (auto i : llvm::seq(sem_ir_->functions().size())) {
|
||||
functions_[i] = BuildFunctionDeclaration(SemIR::FunctionId(i));
|
||||
functions_[i] = BuildFunctionDecl(SemIR::FunctionId(i));
|
||||
}
|
||||
|
||||
// TODO: Lower global variable declarations.
|
||||
@@ -63,7 +63,7 @@ auto FileContext::GetGlobal(SemIR::InstId inst_id) -> llvm::Value* {
|
||||
}
|
||||
|
||||
auto target = sem_ir().insts().Get(inst_id);
|
||||
if (auto function_decl = target.TryAs<SemIR::FunctionDeclaration>()) {
|
||||
if (auto function_decl = target.TryAs<SemIR::FunctionDecl>()) {
|
||||
return GetFunction(function_decl->function_id);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ auto FileContext::GetGlobal(SemIR::InstId inst_id) -> llvm::Value* {
|
||||
CARBON_FATAL() << "Missing value: " << inst_id << " " << target;
|
||||
}
|
||||
|
||||
auto FileContext::BuildFunctionDeclaration(SemIR::FunctionId function_id)
|
||||
auto FileContext::BuildFunctionDecl(SemIR::FunctionId function_id)
|
||||
-> llvm::Function* {
|
||||
const auto& function = sem_ir().functions().Get(function_id);
|
||||
const bool has_return_slot = function.return_slot_id.is_valid();
|
||||
@@ -186,7 +186,7 @@ auto FileContext::BuildFunctionDefinition(SemIR::FunctionId function_id)
|
||||
|
||||
// Add parameters to locals.
|
||||
// TODO: This duplicates the mapping between sem_ir instructions and LLVM
|
||||
// function parameters that was already computed in BuildFunctionDeclaration.
|
||||
// function parameters that was already computed in BuildFunctionDecl.
|
||||
// We should only do that once.
|
||||
auto implicit_param_refs =
|
||||
sem_ir().inst_blocks().Get(function.implicit_param_refs_id);
|
||||
|
||||
@@ -56,8 +56,7 @@ class FileContext {
|
||||
private:
|
||||
// Builds the declaration for the given function, which should then be cached
|
||||
// by the caller.
|
||||
auto BuildFunctionDeclaration(SemIR::FunctionId function_id)
|
||||
-> llvm::Function*;
|
||||
auto BuildFunctionDecl(SemIR::FunctionId function_id) -> llvm::Function*;
|
||||
|
||||
// Builds the definition for the given function. If the function is only a
|
||||
// declaration with no definition, does nothing.
|
||||
|
||||
@@ -179,9 +179,8 @@ auto HandleDereference(FunctionContext& context, SemIR::InstId inst_id,
|
||||
context.SetLocal(inst_id, context.GetValue(inst.pointer_id));
|
||||
}
|
||||
|
||||
auto HandleFunctionDeclaration(FunctionContext& /*context*/,
|
||||
SemIR::InstId /*inst_id*/,
|
||||
SemIR::FunctionDeclaration inst) -> void {
|
||||
auto HandleFunctionDecl(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/,
|
||||
SemIR::FunctionDecl inst) -> void {
|
||||
CARBON_FATAL()
|
||||
<< "Should not be encountered. If that changes, we may want to change "
|
||||
"higher-level logic to skip them rather than calling this. "
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
|
||||
namespace Carbon::Lower {
|
||||
|
||||
auto HandleClassDeclaration(FunctionContext& /*context*/,
|
||||
SemIR::InstId /*inst_id*/,
|
||||
SemIR::ClassDeclaration /*inst*/) -> void {
|
||||
auto HandleClassDecl(FunctionContext& /*context*/, SemIR::InstId /*inst_id*/,
|
||||
SemIR::ClassDecl /*inst*/) -> void {
|
||||
// No action to perform.
|
||||
}
|
||||
|
||||
|
||||
+20
-22
@@ -391,33 +391,33 @@ auto Context::ConsumeListToken(NodeKind comma_kind, Lex::TokenKind close_kind,
|
||||
}
|
||||
}
|
||||
|
||||
auto Context::GetDeclarationContext() -> DeclarationContext {
|
||||
// i == 0 is the file-level DeclarationScopeLoop. Additionally, i == 1 can be
|
||||
// skipped because it will never be a DeclarationScopeLoop.
|
||||
auto Context::GetDeclContext() -> DeclContext {
|
||||
// i == 0 is the file-level DeclScopeLoop. Additionally, i == 1 can be
|
||||
// skipped because it will never be a DeclScopeLoop.
|
||||
for (int i = state_stack_.size() - 1; i > 1; --i) {
|
||||
// The declaration context is always the state _above_ a
|
||||
// DeclarationScopeLoop.
|
||||
if (state_stack_[i].state == State::DeclarationScopeLoop) {
|
||||
// DeclScopeLoop.
|
||||
if (state_stack_[i].state == State::DeclScopeLoop) {
|
||||
switch (state_stack_[i - 1].state) {
|
||||
case State::TypeDefinitionFinishAsClass:
|
||||
return DeclarationContext::Class;
|
||||
return DeclContext::Class;
|
||||
case State::TypeDefinitionFinishAsInterface:
|
||||
return DeclarationContext::Interface;
|
||||
return DeclContext::Interface;
|
||||
case State::TypeDefinitionFinishAsNamedConstraint:
|
||||
return DeclarationContext::NamedConstraint;
|
||||
return DeclContext::NamedConstraint;
|
||||
default:
|
||||
llvm_unreachable("Missing handling for a declaration scope");
|
||||
}
|
||||
}
|
||||
}
|
||||
CARBON_CHECK(!state_stack_.empty() &&
|
||||
state_stack_[0].state == State::DeclarationScopeLoop);
|
||||
return DeclarationContext::File;
|
||||
state_stack_[0].state == State::DeclScopeLoop);
|
||||
return DeclContext::File;
|
||||
}
|
||||
|
||||
auto Context::RecoverFromDeclarationError(StateStackEntry state,
|
||||
NodeKind parse_node_kind,
|
||||
bool skip_past_likely_end) -> void {
|
||||
auto Context::RecoverFromDeclError(StateStackEntry state,
|
||||
NodeKind parse_node_kind,
|
||||
bool skip_past_likely_end) -> void {
|
||||
auto token = state.token;
|
||||
if (skip_past_likely_end) {
|
||||
if (auto semi = SkipPastLikelyEnd(token)) {
|
||||
@@ -428,21 +428,19 @@ auto Context::RecoverFromDeclarationError(StateStackEntry state,
|
||||
/*has_error=*/true);
|
||||
}
|
||||
|
||||
auto Context::EmitExpectedDeclarationSemi(Lex::TokenKind expected_kind)
|
||||
-> void {
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclarationSemi, Error,
|
||||
auto Context::EmitExpectedDeclSemi(Lex::TokenKind expected_kind) -> void {
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclSemi, Error,
|
||||
"`{0}` declarations must end with a `;`.", Lex::TokenKind);
|
||||
emitter().Emit(*position(), ExpectedDeclarationSemi, expected_kind);
|
||||
emitter().Emit(*position(), ExpectedDeclSemi, expected_kind);
|
||||
}
|
||||
|
||||
auto Context::EmitExpectedDeclarationSemiOrDefinition(
|
||||
Lex::TokenKind expected_kind) -> void {
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclarationSemiOrDefinition, Error,
|
||||
auto Context::EmitExpectedDeclSemiOrDefinition(Lex::TokenKind expected_kind)
|
||||
-> void {
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclSemiOrDefinition, Error,
|
||||
"`{0}` declarations must either end with a `;` or "
|
||||
"have a `{{ ... }` block for a definition.",
|
||||
Lex::TokenKind);
|
||||
emitter().Emit(*position(), ExpectedDeclarationSemiOrDefinition,
|
||||
expected_kind);
|
||||
emitter().Emit(*position(), ExpectedDeclSemiOrDefinition, expected_kind);
|
||||
}
|
||||
|
||||
auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void {
|
||||
|
||||
+10
-12
@@ -36,8 +36,8 @@ class Context {
|
||||
Let
|
||||
};
|
||||
|
||||
// Supported return values for GetDeclarationContext.
|
||||
enum class DeclarationContext : int8_t {
|
||||
// Supported return values for GetDeclContext.
|
||||
enum class DeclContext : int8_t {
|
||||
File, // Top-level context.
|
||||
Class,
|
||||
Interface,
|
||||
@@ -48,11 +48,11 @@ class Context {
|
||||
enum class PackagingState : int8_t {
|
||||
StartOfFile,
|
||||
InImports,
|
||||
AfterNonPackagingDeclaration,
|
||||
AfterNonPackagingDecl,
|
||||
// A warning about `import` placement has been issued so we don't keep
|
||||
// issuing more (when `import` is repeated) until more non-`import`
|
||||
// declarations come up.
|
||||
InImportsAfterNonPackagingDeclaration,
|
||||
InImportsAfterNonPackagingDecl,
|
||||
};
|
||||
|
||||
// Used to track state on state_stack_.
|
||||
@@ -266,8 +266,8 @@ class Context {
|
||||
// parses should only need to look down a couple steps.
|
||||
//
|
||||
// This currently assumes it's being called from within the declaration's
|
||||
// DeclarationScopeLoop.
|
||||
auto GetDeclarationContext() -> DeclarationContext;
|
||||
// DeclScopeLoop.
|
||||
auto GetDeclContext() -> DeclContext;
|
||||
|
||||
// Propagates an error up the state stack, to the parent state.
|
||||
auto ReturnErrorOnState() -> void { state_stack_.back().has_error = true; }
|
||||
@@ -277,19 +277,17 @@ class Context {
|
||||
State keyword_state, int subtree_start) -> void;
|
||||
|
||||
// Emits a diagnostic for a declaration missing a semi.
|
||||
auto EmitExpectedDeclarationSemi(Lex::TokenKind expected_kind) -> void;
|
||||
auto EmitExpectedDeclSemi(Lex::TokenKind expected_kind) -> void;
|
||||
|
||||
// Emits a diagnostic for a declaration missing a semi or definition.
|
||||
auto EmitExpectedDeclarationSemiOrDefinition(Lex::TokenKind expected_kind)
|
||||
-> void;
|
||||
auto EmitExpectedDeclSemiOrDefinition(Lex::TokenKind expected_kind) -> void;
|
||||
|
||||
// Handles error recovery in a declaration, particularly before any possible
|
||||
// definition has started (although one could be present). Recover to a
|
||||
// semicolon when it makes sense as a possible end, otherwise use the
|
||||
// introducer token for the error.
|
||||
auto RecoverFromDeclarationError(StateStackEntry state,
|
||||
NodeKind parse_node_kind,
|
||||
bool skip_past_likely_end) -> void;
|
||||
auto RecoverFromDeclError(StateStackEntry state, NodeKind parse_node_kind,
|
||||
bool skip_past_likely_end) -> void;
|
||||
|
||||
// Prints information for a stack dump.
|
||||
auto PrintForStackDump(llvm::raw_ostream& output) const -> void;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
namespace Carbon::Parse {
|
||||
|
||||
// Handles DeclarationNameAndParamsAs(Optional|Required).
|
||||
static auto HandleDeclarationNameAndParams(Context& context, State after_name)
|
||||
// Handles DeclNameAndParamsAs(Optional|Required).
|
||||
static auto HandleDeclNameAndParams(Context& context, State after_name)
|
||||
-> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
@@ -18,16 +18,16 @@ static auto HandleDeclarationNameAndParams(Context& context, State after_name)
|
||||
|
||||
if (context.PositionIs(Lex::TokenKind::Period)) {
|
||||
context.AddLeafNode(NodeKind::Name, *identifier);
|
||||
state.state = State::PeriodAsDeclaration;
|
||||
state.state = State::PeriodAsDecl;
|
||||
context.PushState(state);
|
||||
} else {
|
||||
context.AddLeafNode(NodeKind::Name, *identifier);
|
||||
}
|
||||
} else {
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclarationName, Error,
|
||||
CARBON_DIAGNOSTIC(ExpectedDeclName, Error,
|
||||
"`{0}` introducer should be followed by a name.",
|
||||
Lex::TokenKind);
|
||||
context.emitter().Emit(*context.position(), ExpectedDeclarationName,
|
||||
context.emitter().Emit(*context.position(), ExpectedDeclName,
|
||||
context.tokens().GetKind(state.token));
|
||||
context.ReturnErrorOnState();
|
||||
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
|
||||
@@ -35,19 +35,16 @@ static auto HandleDeclarationNameAndParams(Context& context, State after_name)
|
||||
}
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAsNone(Context& context) -> void {
|
||||
HandleDeclarationNameAndParams(
|
||||
context, State::DeclarationNameAndParamsAfterNameAsNone);
|
||||
auto HandleDeclNameAndParamsAsNone(Context& context) -> void {
|
||||
HandleDeclNameAndParams(context, State::DeclNameAndParamsAfterNameAsNone);
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAsOptional(Context& context) -> void {
|
||||
HandleDeclarationNameAndParams(
|
||||
context, State::DeclarationNameAndParamsAfterNameAsOptional);
|
||||
auto HandleDeclNameAndParamsAsOptional(Context& context) -> void {
|
||||
HandleDeclNameAndParams(context, State::DeclNameAndParamsAfterNameAsOptional);
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAsRequired(Context& context) -> void {
|
||||
HandleDeclarationNameAndParams(
|
||||
context, State::DeclarationNameAndParamsAfterNameAsRequired);
|
||||
auto HandleDeclNameAndParamsAsRequired(Context& context) -> void {
|
||||
HandleDeclNameAndParams(context, State::DeclNameAndParamsAfterNameAsRequired);
|
||||
}
|
||||
|
||||
enum class Params : int8_t {
|
||||
@@ -56,14 +53,14 @@ enum class Params : int8_t {
|
||||
Required,
|
||||
};
|
||||
|
||||
static auto HandleDeclarationNameAndParamsAfterName(Context& context,
|
||||
Params params) -> void {
|
||||
static auto HandleDeclNameAndParamsAfterName(Context& context, Params params)
|
||||
-> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
if (context.PositionIs(Lex::TokenKind::Period)) {
|
||||
// Continue designator processing.
|
||||
context.PushState(state);
|
||||
state.state = State::PeriodAsDeclaration;
|
||||
state.state = State::PeriodAsDecl;
|
||||
context.PushState(state);
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +70,7 @@ static auto HandleDeclarationNameAndParamsAfterName(Context& context,
|
||||
//
|
||||
// fn Class(T:! type).AnotherClass(U:! type).Function(v: T) {}
|
||||
//
|
||||
// We should retain a `DeclarationNameAndParams...` state on the stack in all
|
||||
// We should retain a `DeclNameAndParams...` state on the stack in all
|
||||
// cases below to check for a period after a parameter list, which indicates
|
||||
// that we've not finished parsing the declaration name.
|
||||
|
||||
@@ -82,7 +79,7 @@ static auto HandleDeclarationNameAndParamsAfterName(Context& context,
|
||||
}
|
||||
|
||||
if (context.PositionIs(Lex::TokenKind::OpenSquareBracket)) {
|
||||
context.PushState(State::DeclarationNameAndParamsAfterImplicit);
|
||||
context.PushState(State::DeclNameAndParamsAfterImplicit);
|
||||
context.PushState(State::ParameterListAsImplicit);
|
||||
} else if (context.PositionIs(Lex::TokenKind::OpenParen)) {
|
||||
context.PushState(State::ParameterListAsRegular);
|
||||
@@ -95,21 +92,19 @@ static auto HandleDeclarationNameAndParamsAfterName(Context& context,
|
||||
}
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAfterNameAsNone(Context& context) -> void {
|
||||
HandleDeclarationNameAndParamsAfterName(context, Params::None);
|
||||
auto HandleDeclNameAndParamsAfterNameAsNone(Context& context) -> void {
|
||||
HandleDeclNameAndParamsAfterName(context, Params::None);
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAfterNameAsOptional(Context& context)
|
||||
-> void {
|
||||
HandleDeclarationNameAndParamsAfterName(context, Params::Optional);
|
||||
auto HandleDeclNameAndParamsAfterNameAsOptional(Context& context) -> void {
|
||||
HandleDeclNameAndParamsAfterName(context, Params::Optional);
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAfterNameAsRequired(Context& context)
|
||||
-> void {
|
||||
HandleDeclarationNameAndParamsAfterName(context, Params::Required);
|
||||
auto HandleDeclNameAndParamsAfterNameAsRequired(Context& context) -> void {
|
||||
HandleDeclNameAndParamsAfterName(context, Params::Required);
|
||||
}
|
||||
|
||||
auto HandleDeclarationNameAndParamsAfterImplicit(Context& context) -> void {
|
||||
auto HandleDeclNameAndParamsAfterImplicit(Context& context) -> void {
|
||||
context.PopAndDiscardState();
|
||||
|
||||
if (context.PositionIs(Lex::TokenKind::OpenParen)) {
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
namespace Carbon::Parse {
|
||||
|
||||
// Handles an unrecognized declaration, adding an error node.
|
||||
static auto HandleUnrecognizedDeclaration(Context& context) -> void {
|
||||
CARBON_DIAGNOSTIC(UnrecognizedDeclaration, Error,
|
||||
static auto HandleUnrecognizedDecl(Context& context) -> void {
|
||||
CARBON_DIAGNOSTIC(UnrecognizedDecl, Error,
|
||||
"Unrecognized declaration introducer.");
|
||||
context.emitter().Emit(*context.position(), UnrecognizedDeclaration);
|
||||
context.emitter().Emit(*context.position(), UnrecognizedDecl);
|
||||
auto cursor = *context.position();
|
||||
auto semi = context.SkipPastLikelyEnd(cursor);
|
||||
// Locate the EmptyDeclaration at the semi when found, but use the
|
||||
// Locate the EmptyDecl at the semi when found, but use the
|
||||
// original cursor location for an error when not.
|
||||
context.AddLeafNode(NodeKind::EmptyDeclaration, semi ? *semi : cursor,
|
||||
context.AddLeafNode(NodeKind::EmptyDecl, semi ? *semi : cursor,
|
||||
/*has_error=*/true);
|
||||
}
|
||||
|
||||
auto HandleDeclarationScopeLoop(Context& context) -> void {
|
||||
auto HandleDeclScopeLoop(Context& context) -> void {
|
||||
// This maintains the current state unless we're at the end of the scope.
|
||||
|
||||
switch (auto position_kind = context.PositionKind()) {
|
||||
@@ -42,12 +42,12 @@ auto HandleDeclarationScopeLoop(Context& context) -> void {
|
||||
// Because a non-packaging keyword was encountered, packaging is complete.
|
||||
// Misplaced packaging keywords may lead to this being re-triggered.
|
||||
if (context.packaging_state() !=
|
||||
Context::PackagingState::AfterNonPackagingDeclaration) {
|
||||
Context::PackagingState::AfterNonPackagingDecl) {
|
||||
if (!context.first_non_packaging_token().is_valid()) {
|
||||
context.set_first_non_packaging_token(*context.position());
|
||||
}
|
||||
context.set_packaging_state(
|
||||
Context::PackagingState::AfterNonPackagingDeclaration);
|
||||
Context::PackagingState::AfterNonPackagingDecl);
|
||||
}
|
||||
switch (position_kind) {
|
||||
// Remaining keywords are only valid after imports are complete, and
|
||||
@@ -74,7 +74,7 @@ auto HandleDeclarationScopeLoop(Context& context) -> void {
|
||||
break;
|
||||
}
|
||||
case Lex::TokenKind::Semi: {
|
||||
context.AddLeafNode(NodeKind::EmptyDeclaration, context.Consume());
|
||||
context.AddLeafNode(NodeKind::EmptyDecl, context.Consume());
|
||||
break;
|
||||
}
|
||||
case Lex::TokenKind::Var: {
|
||||
@@ -86,7 +86,7 @@ auto HandleDeclarationScopeLoop(Context& context) -> void {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
HandleUnrecognizedDeclaration(context);
|
||||
HandleUnrecognizedDecl(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ auto HandleFunctionIntroducer(Context& context) -> void {
|
||||
|
||||
state.state = State::FunctionAfterParameters;
|
||||
context.PushState(state);
|
||||
context.PushState(State::DeclarationNameAndParamsAsRequired, state.token);
|
||||
context.PushState(State::DeclNameAndParamsAsRequired, state.token);
|
||||
}
|
||||
|
||||
auto HandleFunctionAfterParameters(Context& context) -> void {
|
||||
@@ -44,21 +44,20 @@ auto HandleFunctionSignatureFinish(Context& context) -> void {
|
||||
|
||||
switch (context.PositionKind()) {
|
||||
case Lex::TokenKind::Semi: {
|
||||
context.AddNode(NodeKind::FunctionDeclaration, context.Consume(),
|
||||
context.AddNode(NodeKind::FunctionDecl, context.Consume(),
|
||||
state.subtree_start, state.has_error);
|
||||
break;
|
||||
}
|
||||
case Lex::TokenKind::OpenCurlyBrace: {
|
||||
if (auto decl_context = context.GetDeclarationContext();
|
||||
decl_context == Context::DeclarationContext::Interface ||
|
||||
decl_context == Context::DeclarationContext::NamedConstraint) {
|
||||
if (auto decl_context = context.GetDeclContext();
|
||||
decl_context == Context::DeclContext::Interface ||
|
||||
decl_context == Context::DeclContext::NamedConstraint) {
|
||||
CARBON_DIAGNOSTIC(
|
||||
MethodImplNotAllowed, Error,
|
||||
"Method implementations are not allowed in interfaces.");
|
||||
context.emitter().Emit(*context.position(), MethodImplNotAllowed);
|
||||
context.RecoverFromDeclarationError(state,
|
||||
NodeKind::FunctionDeclaration,
|
||||
/*skip_past_likely_end=*/true);
|
||||
context.RecoverFromDeclError(state, NodeKind::FunctionDecl,
|
||||
/*skip_past_likely_end=*/true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -73,14 +72,14 @@ auto HandleFunctionSignatureFinish(Context& context) -> void {
|
||||
}
|
||||
default: {
|
||||
if (!state.has_error) {
|
||||
context.EmitExpectedDeclarationSemiOrDefinition(Lex::TokenKind::Fn);
|
||||
context.EmitExpectedDeclSemiOrDefinition(Lex::TokenKind::Fn);
|
||||
}
|
||||
// Only need to skip if we've not already found a new line.
|
||||
bool skip_past_likely_end =
|
||||
context.tokens().GetLine(*context.position()) ==
|
||||
context.tokens().GetLine(state.token);
|
||||
context.RecoverFromDeclarationError(state, NodeKind::FunctionDeclaration,
|
||||
skip_past_likely_end);
|
||||
context.RecoverFromDeclError(state, NodeKind::FunctionDecl,
|
||||
skip_past_likely_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ static auto HandleImportAndPackage(Context& context,
|
||||
}
|
||||
|
||||
if (!context.PositionIs(Lex::TokenKind::Semi)) {
|
||||
context.EmitExpectedDeclarationSemi(context.tokens().GetKind(state.token));
|
||||
context.EmitExpectedDeclSemi(context.tokens().GetKind(state.token));
|
||||
ExitOnParseError(context, state, directive);
|
||||
return;
|
||||
}
|
||||
@@ -110,22 +110,22 @@ auto HandleImport(Context& context) -> void {
|
||||
/*expect_api_or_impl=*/false);
|
||||
break;
|
||||
|
||||
case Context::PackagingState::AfterNonPackagingDeclaration: {
|
||||
case Context::PackagingState::AfterNonPackagingDecl: {
|
||||
context.set_packaging_state(
|
||||
Context::PackagingState::InImportsAfterNonPackagingDeclaration);
|
||||
Context::PackagingState::InImportsAfterNonPackagingDecl);
|
||||
CARBON_DIAGNOSTIC(
|
||||
ImportTooLate, Error,
|
||||
"`import` directives must come after the `package` directive (if "
|
||||
"present) and before any other entities in the file.");
|
||||
CARBON_DIAGNOSTIC(FirstDeclaration, Note, "First declaration is here.");
|
||||
CARBON_DIAGNOSTIC(FirstDecl, Note, "First declaration is here.");
|
||||
context.emitter()
|
||||
.Build(intro_token, ImportTooLate)
|
||||
.Note(context.first_non_packaging_token(), FirstDeclaration)
|
||||
.Note(context.first_non_packaging_token(), FirstDecl)
|
||||
.Emit();
|
||||
ExitOnParseError(context, state, NodeKind::ImportDirective);
|
||||
break;
|
||||
}
|
||||
case Context::PackagingState::InImportsAfterNonPackagingDeclaration:
|
||||
case Context::PackagingState::InImportsAfterNonPackagingDecl:
|
||||
// There is a sequential block of misplaced `import` statements, which can
|
||||
// occur if a declaration is added above `import`s. Avoid duplicate
|
||||
// warnings.
|
||||
|
||||
@@ -48,13 +48,13 @@ auto HandleLetFinish(Context& context) -> void {
|
||||
if (context.PositionIs(Lex::TokenKind::Semi)) {
|
||||
end_token = context.Consume();
|
||||
} else {
|
||||
context.EmitExpectedDeclarationSemi(Lex::TokenKind::Let);
|
||||
context.EmitExpectedDeclSemi(Lex::TokenKind::Let);
|
||||
state.has_error = true;
|
||||
if (auto semi_token = context.SkipPastLikelyEnd(state.token)) {
|
||||
end_token = *semi_token;
|
||||
}
|
||||
}
|
||||
context.AddNode(NodeKind::LetDeclaration, end_token, state.subtree_start,
|
||||
context.AddNode(NodeKind::LetDecl, end_token, state.subtree_start,
|
||||
state.has_error);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ auto HandleNamespace(Context& context) -> void {
|
||||
state.state = State::NamespaceFinish;
|
||||
context.PushState(state);
|
||||
|
||||
context.PushState(State::DeclarationNameAndParamsAsNone, state.token);
|
||||
context.PushState(State::DeclNameAndParamsAsNone, state.token);
|
||||
}
|
||||
|
||||
auto HandleNamespaceFinish(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
if (state.has_error) {
|
||||
context.RecoverFromDeclarationError(state, NodeKind::Namespace,
|
||||
/*skip_past_likely_end=*/true);
|
||||
context.RecoverFromDeclError(state, NodeKind::Namespace,
|
||||
/*skip_past_likely_end=*/true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ auto HandleNamespaceFinish(Context& context) -> void {
|
||||
context.AddNode(NodeKind::Namespace, *semi, state.subtree_start,
|
||||
state.has_error);
|
||||
} else {
|
||||
context.EmitExpectedDeclarationSemi(Lex::TokenKind::Namespace);
|
||||
context.RecoverFromDeclarationError(state, NodeKind::Namespace,
|
||||
/*skip_past_likely_end=*/true);
|
||||
context.EmitExpectedDeclSemi(Lex::TokenKind::Namespace);
|
||||
context.RecoverFromDeclError(state, NodeKind::Namespace,
|
||||
/*skip_past_likely_end=*/true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ static auto HandlePeriodOrArrow(Context& context, NodeKind node_kind,
|
||||
context.AddNode(node_kind, dot, state.subtree_start, state.has_error);
|
||||
}
|
||||
|
||||
auto HandlePeriodAsDeclaration(Context& context) -> void {
|
||||
HandlePeriodOrArrow(context, NodeKind::QualifiedDeclaration,
|
||||
auto HandlePeriodAsDecl(Context& context) -> void {
|
||||
HandlePeriodOrArrow(context, NodeKind::QualifiedDecl,
|
||||
/*is_arrow=*/false);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ auto HandleStatementForHeader(Context& context) -> void {
|
||||
context.PushState(state);
|
||||
context.PushState(State::VarAsFor);
|
||||
} else {
|
||||
CARBON_DIAGNOSTIC(ExpectedVariableDeclaration, Error,
|
||||
CARBON_DIAGNOSTIC(ExpectedVariableDecl, Error,
|
||||
"Expected `var` declaration.");
|
||||
context.emitter().Emit(*context.position(), ExpectedVariableDeclaration);
|
||||
context.emitter().Emit(*context.position(), ExpectedVariableDecl);
|
||||
|
||||
if (auto next_in = context.FindNextOf({Lex::TokenKind::In})) {
|
||||
context.SkipTo(*next_in);
|
||||
|
||||
@@ -15,7 +15,7 @@ static auto HandleTypeIntroducer(Context& context, NodeKind introducer_kind,
|
||||
|
||||
state.state = after_params_state;
|
||||
context.PushState(state);
|
||||
context.PushState(State::DeclarationNameAndParamsAsOptional, state.token);
|
||||
context.PushState(State::DeclNameAndParamsAsOptional, state.token);
|
||||
}
|
||||
|
||||
auto HandleTypeIntroducerAsClass(Context& context) -> void {
|
||||
@@ -35,52 +35,51 @@ auto HandleTypeIntroducerAsNamedConstraint(Context& context) -> void {
|
||||
|
||||
// Handles processing after params, deciding whether it's a declaration or
|
||||
// definition.
|
||||
static auto HandleTypeAfterParams(Context& context, NodeKind declaration_kind,
|
||||
static auto HandleTypeAfterParams(Context& context, NodeKind decl_kind,
|
||||
NodeKind definition_start_kind,
|
||||
State definition_finish_state) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
if (state.has_error) {
|
||||
context.RecoverFromDeclarationError(state, declaration_kind,
|
||||
/*skip_past_likely_end=*/true);
|
||||
context.RecoverFromDeclError(state, decl_kind,
|
||||
/*skip_past_likely_end=*/true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto semi = context.ConsumeIf(Lex::TokenKind::Semi)) {
|
||||
context.AddNode(declaration_kind, *semi, state.subtree_start,
|
||||
state.has_error);
|
||||
context.AddNode(decl_kind, *semi, state.subtree_start, state.has_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.PositionIs(Lex::TokenKind::OpenCurlyBrace)) {
|
||||
context.EmitExpectedDeclarationSemiOrDefinition(
|
||||
context.EmitExpectedDeclSemiOrDefinition(
|
||||
context.tokens().GetKind(state.token));
|
||||
context.RecoverFromDeclarationError(state, declaration_kind,
|
||||
/*skip_past_likely_end=*/true);
|
||||
context.RecoverFromDeclError(state, decl_kind,
|
||||
/*skip_past_likely_end=*/true);
|
||||
return;
|
||||
}
|
||||
|
||||
state.state = definition_finish_state;
|
||||
context.PushState(state);
|
||||
context.PushState(State::DeclarationScopeLoop);
|
||||
context.PushState(State::DeclScopeLoop);
|
||||
context.AddNode(definition_start_kind, context.Consume(), state.subtree_start,
|
||||
state.has_error);
|
||||
}
|
||||
|
||||
auto HandleTypeAfterParamsAsClass(Context& context) -> void {
|
||||
HandleTypeAfterParams(context, NodeKind::ClassDeclaration,
|
||||
HandleTypeAfterParams(context, NodeKind::ClassDecl,
|
||||
NodeKind::ClassDefinitionStart,
|
||||
State::TypeDefinitionFinishAsClass);
|
||||
}
|
||||
|
||||
auto HandleTypeAfterParamsAsInterface(Context& context) -> void {
|
||||
HandleTypeAfterParams(context, NodeKind::InterfaceDeclaration,
|
||||
HandleTypeAfterParams(context, NodeKind::InterfaceDecl,
|
||||
NodeKind::InterfaceDefinitionStart,
|
||||
State::TypeDefinitionFinishAsInterface);
|
||||
}
|
||||
|
||||
auto HandleTypeAfterParamsAsNamedConstraint(Context& context) -> void {
|
||||
HandleTypeAfterParams(context, NodeKind::NamedConstraintDeclaration,
|
||||
HandleTypeAfterParams(context, NodeKind::NamedConstraintDecl,
|
||||
NodeKind::NamedConstraintDefinitionStart,
|
||||
State::TypeDefinitionFinishAsNamedConstraint);
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ auto HandleVarFinishAsSemicolon(Context& context) -> void {
|
||||
end_token = context.Consume();
|
||||
} else {
|
||||
// TODO: Disambiguate between statement and member declaration.
|
||||
context.EmitExpectedDeclarationSemi(Lex::TokenKind::Var);
|
||||
context.EmitExpectedDeclSemi(Lex::TokenKind::Var);
|
||||
state.has_error = true;
|
||||
if (auto semi_token = context.SkipPastLikelyEnd(state.token)) {
|
||||
end_token = *semi_token;
|
||||
}
|
||||
}
|
||||
context.AddNode(NodeKind::VariableDeclaration, end_token, state.subtree_start,
|
||||
context.AddNode(NodeKind::VariableDecl, end_token, state.subtree_start,
|
||||
state.has_error);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ CARBON_PARSE_NODE_KIND_CHILD_COUNT(InvalidParse, 0,
|
||||
CARBON_IF_ERROR(CARBON_ANY_TOKEN))
|
||||
|
||||
// An empty declaration, such as `;`.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(EmptyDeclaration, 0,
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(EmptyDecl, 0,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_ANY_TOKEN))
|
||||
|
||||
@@ -125,7 +125,7 @@ CARBON_PARSE_NODE_KIND_BRACKET(ImportDirective, ImportIntroducer,
|
||||
|
||||
// `namespace`:
|
||||
// NamespaceStart
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// Namespace
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(NamespaceStart, 0, CARBON_TOKEN(Namespace))
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(Namespace, 2, CARBON_TOKEN(Semi))
|
||||
@@ -143,7 +143,7 @@ CARBON_PARSE_NODE_KIND_BRACKET(CodeBlock, CodeBlockStart,
|
||||
|
||||
// `fn`:
|
||||
// FunctionIntroducer
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// _external_: ParameterList
|
||||
// _external_: type expression
|
||||
// ReturnType
|
||||
@@ -153,14 +153,14 @@ CARBON_PARSE_NODE_KIND_BRACKET(CodeBlock, CodeBlockStart,
|
||||
//
|
||||
// The above is the structure for a definition; for a declaration,
|
||||
// FunctionDefinitionStart and later nodes are removed and replaced by
|
||||
// FunctionDeclaration.
|
||||
// FunctionDecl.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(FunctionIntroducer, 0, CARBON_TOKEN(Fn))
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(ReturnType, 1, CARBON_TOKEN(MinusGreater))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(FunctionDefinitionStart, FunctionIntroducer,
|
||||
CARBON_TOKEN(OpenCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(FunctionDefinition, FunctionDefinitionStart,
|
||||
CARBON_TOKEN(CloseCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(FunctionDeclaration, FunctionIntroducer,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(FunctionDecl, FunctionIntroducer,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(Fn)))
|
||||
|
||||
@@ -216,10 +216,10 @@ CARBON_PARSE_NODE_KIND_CHILD_COUNT(Template, 1, CARBON_TOKEN(Template))
|
||||
// _external_: PatternBinding
|
||||
// LetInitializer
|
||||
// _external_: expression
|
||||
// LetDeclaration
|
||||
// LetDecl
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(LetIntroducer, 0, CARBON_TOKEN(Let))
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(LetInitializer, 0, CARBON_TOKEN(Equal))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(LetDeclaration, LetIntroducer,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(LetDecl, LetIntroducer,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(Let)))
|
||||
|
||||
@@ -228,13 +228,13 @@ CARBON_PARSE_NODE_KIND_BRACKET(LetDeclaration, LetIntroducer,
|
||||
// _external_: PatternBinding
|
||||
// _optional_ VariableInitializer
|
||||
// _optional_ _external_: expression
|
||||
// VariableDeclaration
|
||||
// VariableDecl
|
||||
//
|
||||
// The VariableInitializer and following expression are paired: either both will
|
||||
// be present, or neither will.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(VariableIntroducer, 0, CARBON_TOKEN(Var))
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(VariableInitializer, 0, CARBON_TOKEN(Equal))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(VariableDeclaration, VariableIntroducer,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(VariableDecl, VariableIntroducer,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(Var)))
|
||||
|
||||
@@ -280,7 +280,7 @@ CARBON_PARSE_NODE_KIND_BRACKET(ReturnStatement, ReturnStatementStart,
|
||||
// _external_: CodeBlock
|
||||
// ForStatement
|
||||
//
|
||||
// Versus a normal `var`, ForIn replaces VariableDeclaration.
|
||||
// Versus a normal `var`, ForIn replaces VariableDecl.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(ForHeaderStart, 0,
|
||||
CARBON_TOKEN(OpenParen)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(For)))
|
||||
@@ -369,14 +369,13 @@ CARBON_PARSE_NODE_KIND_BRACKET(CallExpr, CallExprStart,
|
||||
CARBON_TOKEN(CloseParen))
|
||||
|
||||
// A qualified declaration, such as `a.b`:
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// _external_: Name
|
||||
// QualifiedDeclaration
|
||||
// QualifiedDecl
|
||||
//
|
||||
// TODO: This will eventually more general expressions, for example with
|
||||
// `GenericType(type_args).ChildType(child_type_args).Name`.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(QualifiedDeclaration, 2,
|
||||
CARBON_TOKEN(Period))
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(QualifiedDecl, 2, CARBON_TOKEN(Period))
|
||||
|
||||
// A member access expression, such as `a.b` or
|
||||
// `GetObject().(Interface.member)`:
|
||||
@@ -527,53 +526,53 @@ CARBON_PARSE_NODE_KIND_BRACKET(StructTypeLiteral,
|
||||
|
||||
// `class`:
|
||||
// ClassIntroducer
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// ClassDefinitionStart
|
||||
// _external_: declarations
|
||||
// ClassDefinition
|
||||
//
|
||||
// The above is the structure for a definition; for a declaration,
|
||||
// ClassDefinitionStart and later nodes are removed and replaced by
|
||||
// ClassDeclaration.
|
||||
// ClassDecl.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(ClassIntroducer, 0, CARBON_TOKEN(Class))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(ClassDefinitionStart, ClassIntroducer,
|
||||
CARBON_TOKEN(OpenCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(ClassDefinition, ClassDefinitionStart,
|
||||
CARBON_TOKEN(CloseCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(ClassDeclaration, ClassIntroducer,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(ClassDecl, ClassIntroducer,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(Class)))
|
||||
|
||||
// `interface`:
|
||||
// InterfaceIntroducer
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// InterfaceDefinitionStart
|
||||
// _external_: declarations
|
||||
// InterfaceDefinition
|
||||
//
|
||||
// The above is the structure for a definition; for a declaration,
|
||||
// InterfaceDefinitionStart and later nodes are removed and replaced by
|
||||
// InterfaceDeclaration.
|
||||
// InterfaceDecl.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(InterfaceIntroducer, 0,
|
||||
CARBON_TOKEN(Interface))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDefinitionStart, InterfaceIntroducer,
|
||||
CARBON_TOKEN(OpenCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDefinition, InterfaceDefinitionStart,
|
||||
CARBON_TOKEN(CloseCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDeclaration, InterfaceIntroducer,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(InterfaceDecl, InterfaceIntroducer,
|
||||
CARBON_TOKEN(Semi)
|
||||
CARBON_IF_ERROR(CARBON_TOKEN(Interface)))
|
||||
|
||||
// `constraint`:
|
||||
// NamedConstraintIntroducer
|
||||
// _external_: Name or QualifiedDeclaration
|
||||
// _external_: Name or QualifiedDecl
|
||||
// NamedConstraintDefinitionStart
|
||||
// _external_: declarations
|
||||
// NamedConstraintDefinition
|
||||
//
|
||||
// The above is the structure for a definition; for a declaration,
|
||||
// NamedConstraintDefinitionStart and later nodes are removed and replaced by
|
||||
// NamedConstraintDeclaration.
|
||||
// NamedConstraintDecl.
|
||||
CARBON_PARSE_NODE_KIND_CHILD_COUNT(NamedConstraintIntroducer, 0,
|
||||
CARBON_TOKEN(Constraint))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDefinitionStart,
|
||||
@@ -582,8 +581,8 @@ CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDefinitionStart,
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDefinition,
|
||||
NamedConstraintDefinitionStart,
|
||||
CARBON_TOKEN(CloseCurlyBrace))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDeclaration,
|
||||
NamedConstraintIntroducer, CARBON_TOKEN(Semi))
|
||||
CARBON_PARSE_NODE_KIND_BRACKET(NamedConstraintDecl, NamedConstraintIntroducer,
|
||||
CARBON_TOKEN(Semi))
|
||||
|
||||
// The `self` value and `Self` type identifier keywords. Typically of the form
|
||||
// `self: Self`:
|
||||
|
||||
@@ -21,7 +21,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(NodeKind, uint8_t) {
|
||||
// tree.
|
||||
class NodeKind : public CARBON_ENUM_BASE(NodeKind) {
|
||||
public:
|
||||
#define CARBON_PARSE_NODE_KIND(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
#define CARBON_PARSE_NODE_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
#include "toolchain/parse/node_kind.def"
|
||||
|
||||
// Returns true if the node is bracketed; otherwise, child_count is used.
|
||||
|
||||
+23
-23
@@ -173,13 +173,13 @@ CARBON_PARSE_STATE(CodeBlockFinish)
|
||||
// - Required: `Foo(...)` or `Foo[...](...)`.
|
||||
//
|
||||
// If `Identifier` followed by `Period`:
|
||||
// 1. DeclarationNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// 1. DeclNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// If `Identifier`:
|
||||
// 1. DeclarationNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// 2. PeriodAsDeclaration
|
||||
// 1. DeclNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// 2. PeriodAsDecl
|
||||
// Else:
|
||||
// (state done)
|
||||
CARBON_PARSE_STATE_VARIANTS3(DeclarationNameAndParams, None, Optional, Required)
|
||||
CARBON_PARSE_STATE_VARIANTS3(DeclNameAndParams, None, Optional, Required)
|
||||
|
||||
// Handles a declaration name between the main name and implicit parameters.
|
||||
//
|
||||
@@ -187,16 +187,16 @@ CARBON_PARSE_STATE_VARIANTS3(DeclarationNameAndParams, None, Optional, Required)
|
||||
// used.
|
||||
//
|
||||
// If `Period`:
|
||||
// 1. DeclarationNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// 2. PeriodAsDeclaration
|
||||
// 1. DeclNameAndParamsAfterNameAs(None|Optional|Required)
|
||||
// 2. PeriodAsDecl
|
||||
// If `OpenSquareBracket`:
|
||||
// 1. ParameterListAsImplicit
|
||||
// 2. DeclarationNameAndParamsAfterImplicit
|
||||
// 2. DeclNameAndParamsAfterImplicit
|
||||
// If `OpenParen`:
|
||||
// 1. ParameterListAsRegular
|
||||
// Else:
|
||||
// (state done)
|
||||
CARBON_PARSE_STATE_VARIANTS3(DeclarationNameAndParamsAfterName, None, Optional,
|
||||
CARBON_PARSE_STATE_VARIANTS3(DeclNameAndParamsAfterName, None, Optional,
|
||||
Required)
|
||||
|
||||
// Handles regular parameters such as `(...)` for the general declaration case.
|
||||
@@ -206,37 +206,37 @@ CARBON_PARSE_STATE_VARIANTS3(DeclarationNameAndParamsAfterName, None, Optional,
|
||||
// 1. ParameterListAsRegular
|
||||
// Else:
|
||||
// (state done)
|
||||
CARBON_PARSE_STATE(DeclarationNameAndParamsAfterImplicit)
|
||||
CARBON_PARSE_STATE(DeclNameAndParamsAfterImplicit)
|
||||
|
||||
// Handles processing of a declaration scope. Things like fn, class, interface,
|
||||
// and so on.
|
||||
//
|
||||
// If `Class`:
|
||||
// 1. TypeIntroducerAsClass
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Constraint`:
|
||||
// 1. TypeIntroducerAsNamedConstraint
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Fn`:
|
||||
// 1. FunctionIntroducer
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Interface`:
|
||||
// 1. TypeIntroducerAsInterface
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Namespace`:
|
||||
// 1. Namespace
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Semi`:
|
||||
// 1. DeclarationScopeLoop
|
||||
// 1. DeclScopeLoop
|
||||
// If `Var`:
|
||||
// 1. VarAsSemicolon
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// If `Let`:
|
||||
// 1. Let
|
||||
// 2. DeclarationScopeLoop
|
||||
// 2. DeclScopeLoop
|
||||
// Else:
|
||||
// (state done)
|
||||
CARBON_PARSE_STATE(DeclarationScopeLoop)
|
||||
CARBON_PARSE_STATE(DeclScopeLoop)
|
||||
|
||||
// Handles periods. Only does one `.<expression>` segment; the source is
|
||||
// responsible for handling chaining.
|
||||
@@ -251,7 +251,7 @@ CARBON_PARSE_STATE(DeclarationScopeLoop)
|
||||
//
|
||||
// Always:
|
||||
// (state done)
|
||||
CARBON_PARSE_STATE_VARIANTS3(Period, Declaration, Expr, Struct)
|
||||
CARBON_PARSE_STATE_VARIANTS3(Period, Decl, Expr, Struct)
|
||||
|
||||
// Handles `->name` expressions. Identical to PeriodAsExpr except for the
|
||||
// leading token.
|
||||
@@ -379,7 +379,7 @@ CARBON_PARSE_STATE(ExprStatementFinish)
|
||||
// If invalid:
|
||||
// (state done)
|
||||
// Else:
|
||||
// 1. DeclarationNameAndParamsAsRequired
|
||||
// 1. DeclNameAndParamsAsRequired
|
||||
// 2. FunctionAfterParameters
|
||||
CARBON_PARSE_STATE(FunctionIntroducer)
|
||||
|
||||
@@ -428,7 +428,7 @@ CARBON_PARSE_STATE(Import)
|
||||
// Handles `namespace`.
|
||||
//
|
||||
// Always:
|
||||
// 1. DeclarationNameAndParamsAsNone
|
||||
// 1. DeclNameAndParamsAsNone
|
||||
// 2. NamespaceFinish
|
||||
CARBON_PARSE_STATE(Namespace)
|
||||
|
||||
@@ -710,7 +710,7 @@ CARBON_PARSE_STATE_VARIANTS3(TypeDefinitionFinish, Class, Interface,
|
||||
// Handles processing of a type's introducer.
|
||||
//
|
||||
// Always:
|
||||
// 1. DeclarationNameAndParamsAsOptional
|
||||
// 1. DeclNameAndParamsAsOptional
|
||||
// 2. TypeAfterParamsAs(Class|Interface|NamedConstraint)
|
||||
CARBON_PARSE_STATE_VARIANTS3(TypeIntroducer, Class, Interface, NamedConstraint)
|
||||
|
||||
@@ -719,7 +719,7 @@ CARBON_PARSE_STATE_VARIANTS3(TypeIntroducer, Class, Interface, NamedConstraint)
|
||||
// If `Semi`:
|
||||
// (state done)
|
||||
// If `OpenCurlyBrace`:
|
||||
// 1. DeclarationScopeLoop
|
||||
// 1. DeclScopeLoop
|
||||
// 2. TypeDefinitionFinishAs(Class|Interface|NamedConstraint)
|
||||
// Else:
|
||||
// (state done)
|
||||
|
||||
@@ -18,7 +18,7 @@ CARBON_DEFINE_RAW_ENUM_CLASS(State, uint8_t) {
|
||||
|
||||
class State : public CARBON_ENUM_BASE(State) {
|
||||
public:
|
||||
#define CARBON_PARSE_STATE(Name) CARBON_ENUM_CONSTANT_DECLARATION(Name)
|
||||
#define CARBON_PARSE_STATE(Name) CARBON_ENUM_CONSTANT_DECL(Name)
|
||||
#include "toolchain/parse/state.def"
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@ var x: [i32;;
|
||||
// CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: 'var', has_error: yes, subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: 'var', has_error: yes, subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ var x: [i32];
|
||||
// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ']', has_error: yes, subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', has_error: yes, subtree_size: 4},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 6},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+1
-1
@@ -17,6 +17,6 @@ var x: [i32; 10];
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '10'},
|
||||
// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ var x: [i32;];
|
||||
// CHECK:STDOUT: {kind: 'ArrayExprSemi', text: ';', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'ArrayExpr', text: ']', subtree_size: 4},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 6},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 8},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+3
-3
@@ -17,20 +17,20 @@ var test_str: String = "Test";
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
|
||||
// CHECK:STDOUT: {kind: 'Name', text: 'test_f64'},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: 'f64'},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '0.1'},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
|
||||
// CHECK:STDOUT: {kind: 'Name', text: 'test_str'},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: 'String'},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '"Test"'},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
// CHECK:STDOUT: - filename: empty_declaration.carbon
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDeclaration', text: ';'},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDecl', text: ';'},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
@@ -12,6 +12,6 @@ foo;
|
||||
// CHECK:STDOUT: - filename: fail_no_intro_with_semi.carbon
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDeclaration', text: ';', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDecl', text: ';', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
@@ -12,6 +12,6 @@ foo bar baz
|
||||
// CHECK:STDOUT: - filename: fail_no_intro_without_semi.carbon
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDeclaration', text: 'foo', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'EmptyDecl', text: 'foo', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
@@ -26,6 +26,6 @@ var = (foo {})
|
||||
// CHECK:STDOUT: {kind: 'ParenExprOrTupleLiteralStart', text: '('},
|
||||
// CHECK:STDOUT: {kind: 'NameExpr', text: 'foo'},
|
||||
// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', has_error: yes, subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: 'var', has_error: yes, subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: 'var', has_error: yes, subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ fn F() {
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '39999999999999999993'},
|
||||
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
|
||||
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 12},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 22},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 22},
|
||||
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
|
||||
// CHECK:STDOUT: {kind: 'Name', text: 'floats'},
|
||||
// CHECK:STDOUT: {kind: 'ArrayExprStart', text: '['},
|
||||
@@ -80,7 +80,7 @@ fn F() {
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: '39999999999999999993.0e39999999999999999993'},
|
||||
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
|
||||
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 16},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 26},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 26},
|
||||
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 54},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ class Foo {
|
||||
// CHECK:STDOUT: {kind: 'Name', text: 'Baz'},
|
||||
// CHECK:STDOUT: {kind: 'ParameterListStart', text: '('},
|
||||
// CHECK:STDOUT: {kind: 'ParameterList', text: ')', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'FunctionDecl', text: ';', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'ClassDefinition', text: '}', subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ class Foo {
|
||||
// CHECK:STDOUT: {kind: 'Name', text: 'x'},
|
||||
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
|
||||
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'ClassDefinition', text: '}', subtree_size: 9},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user