mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
* change all expression and statement pointers to be const * const in paren tests
32 lines
803 B
C++
32 lines
803 B
C++
// 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
|
|
|
|
#include "executable_semantics/ast/member.h"
|
|
|
|
#include <iostream>
|
|
|
|
namespace Carbon {
|
|
|
|
auto MakeField(int line_num, std::string name, const Expression* type)
|
|
-> Member* {
|
|
auto m = new Member();
|
|
m->line_num = line_num;
|
|
m->tag = MemberKind::FieldMember;
|
|
m->u.field.name = new std::string(std::move(name));
|
|
m->u.field.type = type;
|
|
return m;
|
|
}
|
|
|
|
void PrintMember(Member* m) {
|
|
switch (m->tag) {
|
|
case MemberKind::FieldMember:
|
|
std::cout << "var " << *m->u.field.name << " : ";
|
|
PrintExp(m->u.field.type);
|
|
std::cout << ";" << std::endl;
|
|
break;
|
|
}
|
|
}
|
|
|
|
} // namespace Carbon
|