Generic classes (#1124)

* start of generic classes

* fix regressions

* class functions in interfaces

* access to class function on interface from class parameter

* more stuff working for generic classes

* fixing bugs

* update TypeEqual for generic classes

* fixing bugs and finding new ones

* disable unqualified access to members from other members for now

* minor edits

* bug fixes

* introduce compile_time_value to use in type checker instead of constant_value

* cleanup

* put a CHECK back in

* failure test cases for the new FATAL_COMPILATION_ERROR

* change a runtime FATAL into a FATAL_COMPILATION_ERROR

* Update executable_semantics/ast/declaration.h

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/action_stack.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/resolve_names.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* responses to reviews

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* rename compile_time_value to symbolic_identity

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/type_checker.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/interpreter/value.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* more edits from review

* Apply suggestions from code review

Co-authored-by: Geoff Romer <gromer@google.com>

* review responses

* Update executable_semantics/interpreter/interpreter.cpp

Co-authored-by: Geoff Romer <gromer@google.com>

* const impl_scope for TypeCheckChoiceDeclaration

* add some const

Co-authored-by: Jon Meow <jperkins@google.com>
Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jeremy G. Siek
2022-03-29 13:09:41 -04:00
committed by GitHub
co-authored by Jon Meow Geoff Romer
parent 37a0e35b31
commit 210856dd57
41 changed files with 1597 additions and 401 deletions
+13 -9
View File
@@ -8,7 +8,6 @@
#include "executable_semantics/ast/declaration.h"
#include "executable_semantics/ast/expression.h"
#include "executable_semantics/ast/generic_binding.h"
#include "llvm/Support/Casting.h"
namespace Carbon {
@@ -240,6 +239,14 @@ static auto BindingPatternToProto(const BindingPattern& pattern)
return pattern_proto;
}
static auto GenericBindingToProto(const GenericBinding& binding)
-> Fuzzing::GenericBinding {
Fuzzing::GenericBinding binding_proto;
binding_proto.set_name(binding.name());
*binding_proto.mutable_type() = ExpressionToProto(binding.type());
return binding_proto;
}
static auto TuplePatternToProto(const TuplePattern& tuple_pattern)
-> Fuzzing::TuplePattern {
Fuzzing::TuplePattern tuple_pattern_proto;
@@ -252,6 +259,11 @@ static auto TuplePatternToProto(const TuplePattern& tuple_pattern)
static auto PatternToProto(const Pattern& pattern) -> Fuzzing::Pattern {
Fuzzing::Pattern pattern_proto;
switch (pattern.kind()) {
case PatternKind::GenericBinding: {
const auto& binding = cast<GenericBinding>(pattern);
*pattern_proto.mutable_generic_binding() = GenericBindingToProto(binding);
break;
}
case PatternKind::BindingPattern: {
const auto& binding = cast<BindingPattern>(pattern);
*pattern_proto.mutable_binding_pattern() = BindingPatternToProto(binding);
@@ -422,14 +434,6 @@ static auto ReturnTermToProto(const ReturnTerm& return_term)
return return_term_proto;
}
static auto GenericBindingToProto(const GenericBinding& binding)
-> Fuzzing::GenericBinding {
Fuzzing::GenericBinding binding_proto;
binding_proto.set_name(binding.name());
*binding_proto.mutable_type() = ExpressionToProto(binding.type());
return binding_proto;
}
static auto DeclarationToProto(const Declaration& declaration)
-> Fuzzing::Declaration {
Fuzzing::Declaration declaration_proto;