2021-04-05 19:02:30 +01:00
|
|
|
/* -*- C++ -*-
|
2021-10-12 20:51:03 +01:00
|
|
|
* Serene Programming Language
|
2020-07-16 15:48:06 +01:00
|
|
|
*
|
2021-10-12 20:51:03 +01:00
|
|
|
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
2020-07-16 15:48:06 +01:00
|
|
|
*
|
2021-10-12 20:51:03 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 2.
|
2020-07-16 15:48:06 +01:00
|
|
|
*
|
2021-10-12 20:51:03 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2020-07-16 15:48:06 +01:00
|
|
|
*
|
2021-10-12 20:51:03 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2020-07-16 15:48:06 +01:00
|
|
|
*/
|
|
|
|
|
2021-10-17 20:12:17 +01:00
|
|
|
#ifndef SERENE_EXPRS_SYMBOL_H
|
|
|
|
#define SERENE_EXPRS_SYMBOL_H
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2021-04-25 09:56:28 +01:00
|
|
|
#include "serene/context.h"
|
2021-04-06 16:20:20 +01:00
|
|
|
#include "serene/exprs/expression.h"
|
2021-06-13 22:58:46 +01:00
|
|
|
|
2021-07-30 12:17:41 +01:00
|
|
|
#include <llvm/ADT/StringRef.h>
|
2021-10-17 20:12:17 +01:00
|
|
|
|
2021-04-05 19:02:30 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace serene {
|
|
|
|
|
|
|
|
namespace exprs {
|
|
|
|
|
2021-04-11 00:02:56 +01:00
|
|
|
/// This data structure represent the Lisp symbol. Just a symbol
|
|
|
|
/// in the context of the AST and nothing else.
|
2021-04-12 23:18:32 +01:00
|
|
|
class Symbol : public Expression {
|
|
|
|
|
|
|
|
public:
|
2021-04-05 19:02:30 +01:00
|
|
|
std::string name;
|
2021-04-06 16:20:20 +01:00
|
|
|
|
2021-04-10 15:36:16 +01:00
|
|
|
Symbol(reader::LocationRange &loc, llvm::StringRef name)
|
|
|
|
: Expression(loc), name(name){};
|
|
|
|
|
2021-05-09 12:21:26 +01:00
|
|
|
Symbol(Symbol &s) : Expression(s.location) { this->name = s.name; }
|
|
|
|
|
2021-09-27 13:05:15 +01:00
|
|
|
ExprType getType() const override;
|
|
|
|
std::string toString() const override;
|
2021-04-10 15:36:16 +01:00
|
|
|
|
2021-10-17 20:12:17 +01:00
|
|
|
MaybeNode analyze(SereneContext & /*ctx*/) override;
|
|
|
|
void generateIR(serene::Namespace & /*ns*/,
|
|
|
|
mlir::ModuleOp & /*m*/) override{};
|
2021-04-12 23:18:32 +01:00
|
|
|
|
2021-04-10 15:36:16 +01:00
|
|
|
~Symbol() = default;
|
2021-07-30 12:17:41 +01:00
|
|
|
|
|
|
|
static bool classof(const Expression *e);
|
2021-04-05 19:02:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace exprs
|
|
|
|
} // namespace serene
|
2020-07-16 15:48:06 +01:00
|
|
|
|
2020-07-10 18:06:26 +01:00
|
|
|
#endif
|