-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Generic objects for generic classes and interfaces. (#4086)
In `ClassType`s and `InterfaceType`s, track a `GenericInstanceId` for the instance rather than just the argument list. --------- Co-authored-by: Jon Ross-Perkins <[email protected]>
- Loading branch information
Showing
78 changed files
with
453 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "toolchain/check/generic.h" | ||
|
||
#include "toolchain/sem_ir/ids.h" | ||
|
||
namespace Carbon::Check { | ||
|
||
auto StartGenericDecl(Context& /*context*/) -> void { | ||
// TODO: Start tracking the contents of this declaration. | ||
} | ||
|
||
auto StartGenericDefinition(Context& /*context*/, | ||
SemIR::GenericId /*generic_id*/) -> void { | ||
// TODO: Start tracking the contents of this definition. | ||
} | ||
|
||
auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) | ||
-> SemIR::GenericId { | ||
if (context.scope_stack().compile_time_binding_stack().empty()) { | ||
return SemIR::GenericId::Invalid; | ||
} | ||
|
||
auto bindings_id = context.inst_blocks().Add( | ||
context.scope_stack().compile_time_binding_stack()); | ||
return context.generics().Add( | ||
SemIR::Generic{.decl_id = decl_id, .bindings_id = bindings_id}); | ||
} | ||
|
||
auto FinishGenericRedecl(Context& /*context*/, SemIR::InstId /*decl_id*/, | ||
SemIR::GenericId /*generic_id*/) -> void { | ||
// TODO: Compare contents of this declaration with the existing one on the | ||
// generic. | ||
} | ||
|
||
auto FinishGenericDefinition(Context& /*context*/, | ||
SemIR::GenericId /*generic_id*/) -> void { | ||
// TODO: Track contents of this generic definition. | ||
} | ||
|
||
} // namespace Carbon::Check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
// Exceptions. See /LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef CARBON_TOOLCHAIN_CHECK_GENERIC_H_ | ||
#define CARBON_TOOLCHAIN_CHECK_GENERIC_H_ | ||
|
||
#include "toolchain/check/context.h" | ||
#include "toolchain/sem_ir/ids.h" | ||
|
||
namespace Carbon::Check { | ||
|
||
// Start processing a declaration or definition that might be a generic entity. | ||
auto StartGenericDecl(Context& /*context*/) -> void; | ||
|
||
// Start processing a declaration or definition that might be a generic entity. | ||
auto StartGenericDefinition(Context& /*context*/, | ||
SemIR::GenericId /*generic_id*/) -> void; | ||
|
||
// Finish processing a potentially generic declaration and produce a | ||
// corresponding generic object. Returns SemIR::GenericId::Invalid if this | ||
// declaration is not actually generic. | ||
auto FinishGenericDecl(Context& context, SemIR::InstId decl_id) | ||
-> SemIR::GenericId; | ||
|
||
// Merge a redeclaration of an entity that might be a generic into the original | ||
// declaration. | ||
auto FinishGenericRedecl(Context& context, SemIR::InstId decl_id, | ||
SemIR::GenericId generic_id) -> void; | ||
|
||
// Finish processing a potentially generic definition. | ||
auto FinishGenericDefinition(Context& context, SemIR::GenericId generic_id) | ||
-> void; | ||
|
||
} // namespace Carbon::Check | ||
|
||
#endif // CARBON_TOOLCHAIN_CHECK_GENERIC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.