mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 22:02:37 +01:00
`Pattern` is intended to pilot some changes I would like to apply to all our sum types: - The alternatives are expressed as derived classes rather than members of a `std::variant`. - The alternatives are classes in the [style guide sense](https://google.github.io/styleguide/cppguide.html#Structs_vs._Classes), meaning they can have invariants, but can't have public data members. - Creating an object is expressed using a constructor rather than a factory function. - Accessing an alternative is expressed as a cast (using LLVM's RTTI system) rather than `std::get` or a `Get` method. Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
128 lines
2.9 KiB
Python
128 lines
2.9 KiB
Python
# 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
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
|
|
package(default_visibility = ["//executable_semantics:__subpackages__"])
|
|
|
|
cc_library(
|
|
name = "declaration",
|
|
srcs = ["declaration.cpp"],
|
|
hdrs = [
|
|
"abstract_syntax_tree.h",
|
|
"declaration.h",
|
|
],
|
|
deps = [
|
|
":function_definition",
|
|
":member",
|
|
":pattern",
|
|
":struct_definition",
|
|
"//common:ostream",
|
|
"//executable_semantics/interpreter:address",
|
|
"//executable_semantics/interpreter:containers",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "expression",
|
|
srcs = ["expression.cpp"],
|
|
hdrs = ["expression.h"],
|
|
deps = [
|
|
"//common:indirect_value",
|
|
"//common:ostream",
|
|
"//executable_semantics/common:arena",
|
|
"//executable_semantics/common:error",
|
|
"//executable_semantics/syntax:paren_contents",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "expression_test",
|
|
srcs = ["expression_test.cpp"],
|
|
env = {
|
|
# TODO(#580): Remove this when leaks are fixed.
|
|
"ASAN_OPTIONS": "detect_leaks=0",
|
|
},
|
|
deps = [
|
|
":expression",
|
|
"//executable_semantics/syntax:paren_contents",
|
|
"@llvm-project//llvm:gtest",
|
|
"@llvm-project//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "function_definition",
|
|
srcs = ["function_definition.cpp"],
|
|
hdrs = ["function_definition.h"],
|
|
deps = [
|
|
":expression",
|
|
":statement",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "member",
|
|
srcs = ["member.cpp"],
|
|
hdrs = ["member.h"],
|
|
deps = [
|
|
":pattern",
|
|
"//common:ostream",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "pattern",
|
|
srcs = ["pattern.cpp"],
|
|
hdrs = ["pattern.h"],
|
|
deps = [
|
|
":expression",
|
|
"//common:ostream",
|
|
"//executable_semantics/common:error",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "pattern_test",
|
|
srcs = ["pattern_test.cpp"],
|
|
env = {
|
|
# TODO(#580): Remove this when leaks are fixed.
|
|
"ASAN_OPTIONS": "detect_leaks=0",
|
|
},
|
|
deps = [
|
|
":pattern",
|
|
"//executable_semantics/syntax:paren_contents",
|
|
"@llvm-project//llvm:Support",
|
|
"@llvm-project//llvm:gtest",
|
|
"@llvm-project//llvm:gtest_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "statement",
|
|
srcs = ["statement.cpp"],
|
|
hdrs = ["statement.h"],
|
|
deps = [
|
|
":expression",
|
|
":pattern",
|
|
"//common:check",
|
|
"//common:ostream",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "struct_definition",
|
|
hdrs = ["struct_definition.h"],
|
|
deps = [
|
|
":member",
|
|
"//common:ostream",
|
|
"@llvm-project//llvm:Support",
|
|
],
|
|
)
|