mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
AST cloning mechanism (#2699)
This is intended to be used for template instantiation, but for now takes no stance as to what it's cloning. This is tested by parsing and cloning all of our test files, and checking that the result of converting each AST to proto is the same as the result of cloning and then converting each AST to proto.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "common/ostream.h"
|
||||
#include "explorer/ast/expression.h"
|
||||
#include "explorer/ast/impl_binding.h"
|
||||
#include "explorer/ast/value.h"
|
||||
#include "explorer/common/arena.h"
|
||||
#include "explorer/common/error_builders.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
@@ -170,4 +172,14 @@ auto ParenExpressionToParenPattern(Nonnull<Arena*> arena,
|
||||
return result;
|
||||
}
|
||||
|
||||
GenericBinding::GenericBinding(CloneContext& context,
|
||||
const GenericBinding& other)
|
||||
: Pattern(context, other),
|
||||
name_(other.name_),
|
||||
type_(context.Clone(other.type_)),
|
||||
symbolic_identity_(context.Clone(other.symbolic_identity_)),
|
||||
impl_binding_(context.Clone(other.impl_binding_)),
|
||||
original_(context.Remap(other.original_)),
|
||||
named_as_type_via_dot_self_(other.named_as_type_via_dot_self_) {}
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user