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:
Richard Smith
2023-03-21 12:36:05 -07:00
committed by GitHub
parent 18c350226f
commit 782bd87316
28 changed files with 1144 additions and 118 deletions
+12
View File
@@ -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