mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:51:09 +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.
421 lines
9.7 KiB
Plaintext
421 lines
9.7 KiB
Plaintext
compilation_unit {
|
|
package_statement {
|
|
package_name: "ExplorerTest"
|
|
}
|
|
is_api: true
|
|
declarations {
|
|
class_declaration {
|
|
name {
|
|
name: "C"
|
|
}
|
|
members {
|
|
variable {
|
|
binding {
|
|
name: "a"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Foo"
|
|
}
|
|
self_pattern {
|
|
binding_pattern {
|
|
name: "self"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Bar"
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
class_declaration {
|
|
name {
|
|
name: "D"
|
|
}
|
|
members {
|
|
variable {
|
|
binding {
|
|
name: "b"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Foo"
|
|
}
|
|
self_pattern {
|
|
binding_pattern {
|
|
name: "self"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Bar"
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "Main"
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "d"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "D"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
struct_literal {
|
|
fields {
|
|
name: "base"
|
|
expression {
|
|
struct_literal {
|
|
fields {
|
|
name: "a"
|
|
expression {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fields {
|
|
name: "b"
|
|
expression {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "c"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
operator {
|
|
op: Ptr
|
|
arguments {
|
|
identifier {
|
|
name: "C"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
operator {
|
|
op: AddressOf
|
|
arguments {
|
|
identifier {
|
|
name: "d"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
expression_statement {
|
|
expression {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "Print"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
string_literal {
|
|
value: "(*c).a: {0}"
|
|
}
|
|
}
|
|
fields {
|
|
simple_member_access {
|
|
field: "a"
|
|
object {
|
|
operator {
|
|
op: Deref
|
|
arguments {
|
|
identifier {
|
|
name: "c"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
expression_statement {
|
|
expression {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "Print"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
string_literal {
|
|
value: "(*c).Foo(): {0}"
|
|
}
|
|
}
|
|
fields {
|
|
call {
|
|
function {
|
|
simple_member_access {
|
|
field: "Foo"
|
|
object {
|
|
operator {
|
|
op: Deref
|
|
arguments {
|
|
identifier {
|
|
name: "c"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
expression_statement {
|
|
expression {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "Print"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
string_literal {
|
|
value: "(*c).Bar(): {0}"
|
|
}
|
|
}
|
|
fields {
|
|
call {
|
|
function {
|
|
simple_member_access {
|
|
field: "Bar"
|
|
object {
|
|
operator {
|
|
op: Deref
|
|
arguments {
|
|
identifier {
|
|
name: "c"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|