Files
carbon-lang/executable_semantics/ast/member.cpp
T
Jon Meow 9829f188b7 Move all new's to global_arena, and remove ASAN disabling (#690)
Note this changes identifiers from char* to string to avoid malloc.

Fixes #580
2021-08-02 11:08:22 -07:00

33 lines
867 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 "executable_semantics/common/arena.h"
namespace Carbon {
auto Member::MakeFieldMember(int line_num, const BindingPattern* binding)
-> Member* {
auto m = global_arena->New<Member>();
m->line_num = line_num;
m->value = FieldMember({.binding = binding});
return m;
}
auto Member::GetFieldMember() const -> const FieldMember& {
return std::get<FieldMember>(value);
}
void Member::Print(llvm::raw_ostream& out) const {
switch (tag()) {
case MemberKind::FieldMember:
const auto& field = GetFieldMember();
out << "var " << field.binding << ";\n";
break;
}
}
} // namespace Carbon