mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 14:00:30 +00: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.
583 lines
14 KiB
Plaintext
583 lines
14 KiB
Plaintext
compilation_unit {
|
|
package_statement {
|
|
package_name: "ExplorerTest"
|
|
}
|
|
is_api: true
|
|
declarations {
|
|
function {
|
|
name {
|
|
name: "identFn"
|
|
}
|
|
param_pattern {
|
|
fields {
|
|
binding_pattern {
|
|
name: "x"
|
|
type {
|
|
expression_pattern {
|
|
expression {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return_term {
|
|
kind: Expression
|
|
type {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
body {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
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 {
|
|
int_type_literal {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
init {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
int_literal {
|
|
value: 7
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
is_returned: false
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
operator {
|
|
op: Mul
|
|
arguments {
|
|
int_literal {
|
|
value: 3
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 3
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 3
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
int_literal {
|
|
value: 4
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 3
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
int_literal {
|
|
value: 15
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Add
|
|
arguments {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "identFn"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
int_literal {
|
|
value: 2
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 4
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
int_literal {
|
|
value: 15
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 7
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 5
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
int_literal {
|
|
value: 15
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
int_literal {
|
|
value: 7
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 6
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
assign {
|
|
lhs {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
rhs {
|
|
operator {
|
|
op: Mod
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
int_literal {
|
|
value: 15
|
|
}
|
|
}
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
call {
|
|
function {
|
|
identifier {
|
|
name: "identFn"
|
|
}
|
|
}
|
|
argument {
|
|
tuple_literal {
|
|
fields {
|
|
int_literal {
|
|
value: 7
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
op: Plain
|
|
}
|
|
}
|
|
statements {
|
|
if_statement {
|
|
condition {
|
|
operator {
|
|
op: NotEq
|
|
arguments {
|
|
identifier {
|
|
name: "x"
|
|
}
|
|
}
|
|
arguments {
|
|
operator {
|
|
op: Neg
|
|
arguments {
|
|
int_literal {
|
|
value: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
then_block {
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 7
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
statements {
|
|
return_expression_statement {
|
|
expression {
|
|
int_literal {
|
|
value: 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|