mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:21:04 +01:00
Support for global variables is still missing; they're a bit more tricky because they use a pattern to introduce their name. Prior to this change, explorer heavily relied on name comparisons to determine whether two declarations declare the same entity. Some of those instances are fixed in this PR, but more remain to be fixed, and some TODOs are added for some harder-to-fix instances.
340 lines
7.1 KiB
Plaintext
340 lines
7.1 KiB
Plaintext
compilation_unit {
|
|
package_statement {
|
|
package_name: "ExplorerTest"
|
|
}
|
|
is_api: true
|
|
declarations {
|
|
interface {
|
|
name {
|
|
name: "HasAssoc"
|
|
}
|
|
members {
|
|
let {
|
|
pattern {
|
|
generic_binding {
|
|
name: "Assoc"
|
|
type {
|
|
type_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
let {
|
|
pattern {
|
|
generic_binding {
|
|
name: "AssocVal"
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
class_declaration {
|
|
name {
|
|
name: "X"
|
|
}
|
|
members {
|
|
impl {
|
|
kind: ExternalImpl
|
|
impl_type {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
interface {
|
|
where {
|
|
base {
|
|
identifier {
|
|
name: "HasAssoc"
|
|
}
|
|
}
|
|
clauses {
|
|
rewrite {
|
|
member_name: "Assoc"
|
|
replacement {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
clauses {
|
|
rewrite {
|
|
member_name: "AssocVal"
|
|
replacement {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "F"
|
|
}
|
|
deduced_parameters {
|
|
name: "T"
|
|
type {
|
|
where {
|
|
base {
|
|
identifier {
|
|
name: "HasAssoc"
|
|
}
|
|
}
|
|
clauses {
|
|
rewrite {
|
|
member_name: "Assoc"
|
|
replacement {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "a"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
simple_member_access {
|
|
field: "Assoc"
|
|
object {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
identifier {
|
|
name: "a"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "G"
|
|
}
|
|
deduced_parameters {
|
|
name: "T"
|
|
type {
|
|
where {
|
|
base {
|
|
identifier {
|
|
name: "HasAssoc"
|
|
}
|
|
}
|
|
clauses {
|
|
rewrite {
|
|
member_name: "AssocVal"
|
|
replacement {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
simple_member_access {
|
|
field: "AssocVal"
|
|
object {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "Main"
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "X"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
struct_literal {
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
operator {
|
|
op: Mul
|
|
arguments {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "F"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 10
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "G"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|