blob: 4efcd411e64fe4c6fca044fbbab5641fb9ac799c [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_DEVELOPER_DEBUG_ZXDB_EXPR_EXPR_LANGUAGE_H_
#define SRC_DEVELOPER_DEBUG_ZXDB_EXPR_EXPR_LANGUAGE_H_
#include <optional>
#include <string>
#include "src/developer/debug/zxdb/symbols/dwarf_lang.h"
namespace zxdb {
// The enum values should be bits so we can store the language applicability for each token in a
// bitfield.
enum class ExprLanguage {
// All C, C++, and Objective C variants. We may need to split out objective C in the future.
kC = 1,
kRust = 2
};
// All non-Rust languages are treated as C.
inline ExprLanguage DwarfLangToExprLanguage(DwarfLang dwarf) {
if (dwarf == DwarfLang::kRust)
return ExprLanguage::kRust;
return ExprLanguage::kC;
}
// Attempts to determine the source language corresponding to a given file name. Returns nullopt
// if no explicit match.
std::optional<ExprLanguage> FileNameToLanguage(const std::string& name);
} // namespace zxdb
#endif // SRC_DEVELOPER_DEBUG_ZXDB_EXPR_EXPR_LANGUAGE_H_