// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// -*- mode: C++ -*-
//
// Copyright 2020-2024 Google LLC
//
// Licensed under the Apache License v2.0 with LLVM Exceptions (the
// "License"); you may not use this file except in compliance with the
// License.  You may obtain a copy of the License at
//
//     https://llvm.org/LICENSE.txt
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Giuliano Procida
// Author: Ignes Simeonova

#ifndef STG_NAMING_H_
#define STG_NAMING_H_

#include <ostream>
#include <string>
#include <unordered_map>

#include "graph.h"

namespace stg {

// See naming.md for conceptual documentation.

enum class Precedence { NIL, POINTER, ARRAY_FUNCTION, ATOMIC };
enum class Side { LEFT, RIGHT };

class Name {
 public:
  explicit Name(const std::string& name)
      : left_(name), precedence_(Precedence::NIL), right_() {}
  Name(const std::string& left, Precedence precedence, const std::string& right)
      : left_(left), precedence_(precedence), right_(right) {}
  Name Add(Side side, Precedence precedence, const std::string& text) const;
  Name Qualify(Qualifier qualifier) const;
  std::ostream& Print(std::ostream& os) const;
  std::string ToString() const;

 private:
  std::string left_;
  Precedence precedence_;
  std::string right_;
};

std::ostream& operator<<(std::ostream& os, const Name& name);

using NameCache = std::unordered_map<Id, Name>;

struct Describe {
  Describe(const Graph& graph, NameCache& names) : graph(graph), names(names) {}
  Name operator()(Id id);
  const Graph& graph;
  NameCache& names;
};

struct DescribeKind {
  explicit DescribeKind(const Graph& graph) : graph(graph) {}
  std::string operator()(Id id);
  const Graph& graph;
};

struct DescribeExtra {
  explicit DescribeExtra(const Graph& graph) : graph(graph) {}
  std::string operator()(Id id);
  const Graph& graph;
};

}  // namespace stg

#endif  // STG_NAMING_H_
