Files
carbon-lang/executable_semantics/ast/member.cpp
T
Jeremy G. Siek 34f1a03f7b change all expression and statement pointers to be const (#449)
* change all expression and statement pointers to be const

* const in paren tests
2021-04-19 21:47:19 -04:00

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