mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:21:21 +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.
345 lines
7.3 KiB
Plaintext
345 lines
7.3 KiB
Plaintext
compilation_unit {
|
|
package_statement {
|
|
package_name: "ExplorerTest"
|
|
}
|
|
is_api: true
|
|
declarations {
|
|
interface {
|
|
name {
|
|
name: "SwizzleWith"
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Op"
|
|
}
|
|
self_pattern {
|
|
binding_pattern {
|
|
name: "self"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
impl {
|
|
kind: InternalImpl
|
|
impl_type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
interface {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "SwizzleWith"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
members {
|
|
function {
|
|
name {
|
|
name: "Op"
|
|
}
|
|
self_pattern {
|
|
binding_pattern {
|
|
name: "self"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
identifier {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
operator {
|
|
op: Mul
|
|
arguments {
|
|
identifier {
|
|
name: "self"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 10
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "F"
|
|
}
|
|
deduced_parameters {
|
|
name: "T"
|
|
type {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "SwizzleWith"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
designator {
|
|
name: "Self"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "v"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
fields {
|
|
binding_pattern {
|
|
name: "w"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
identifier {
|
|
name: "T"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
call {
|
|
function {
|
|
simple_member_access {
|
|
field: "Op"
|
|
object {
|
|
identifier {
|
|
name: "v"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
identifier {
|
|
name: "w"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "Main"
|
|
}
|
|
param_pattern {
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "one"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
variable_definition {
|
|
pattern {
|
|
binding_pattern {
|
|
name: "two"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "F"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
identifier {
|
|
name: "one"
|
|
}
|
|
}
|
|
fields {
|
|
identifier {
|
|
name: "two"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|