//============================================================================//
// //
// artichoke programming language //
// //
// Copyright (C) 2025 Erick Saul Guzman Ramos, whoami.artichoke.dev //
// //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as published //
// by the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// 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 Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see . //
// //
//============================================================================//
#pragma once
#include
#include
namespace arti::lang::sym {
struct Function;
struct FunctionType;
struct Enum;
struct EnumMember;
struct Struct;
struct StructMember;
struct Variable;
struct Primitive;
struct TypeSymbol;
struct TemplateParam;
struct TemplatedSymbol;
using Symbol = std::variant<
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr,
SharedPtr
>;
using WeakSymbol = std::variant<
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr
>;
struct SymbolTable {
String name;
SourceLocation location;
WeakPtr parent;
HashMap> inner;
HashMap symbols;
};
struct Function {
String name;
SourceLocation location;
WeakPtr parent;
SharedPtr body;
WeakPtr type;
};
struct FunctionType {
String name;
SourceLocation location;
WeakPtr parent;
WeakPtr symbol;
Vector> arguments;
Optional> returnType;
};
struct EnumMember {
String name;
SourceLocation location;
std::uint64_t index;
Optional> type;
};
struct Enum {
String name;
SourceLocation location;
WeakPtr parent;
std::uint64_t size;
std::uint64_t alignment;
Vector membersList;
HashMap membersLookup;
HashMap> methods;
};
struct StructMember {
String name;
SourceLocation location;
std::uint64_t index;
std::uint64_t offset;
WeakPtr type;
};
struct Struct {
String name;
SourceLocation location;
WeakPtr parent;
std::uint64_t size;
std::uint64_t alignment;
Vector membersList;
HashMap membersLookup;
HashMap> methods;
};
struct TemplateParam {
String name;
SourceLocation location;
WeakPtr parent;
};
struct TemplatedSymbol {
String name;
SourceLocation location;
WeakPtr parent;
/* It's parent is ^ */
WeakPtr scope;
/* Lives in scope */
WeakSymbol symbol;
Vector params;
};
struct Variable {
String name;
SourceLocation location;
WeakPtr type;
};
struct Primitive {
String name;
std::uint64_t size;
std::uint64_t alignment;
};
struct TypeSymbol {
using Type = std::variant<
SharedPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr,
WeakPtr
>;
Type type;
Optional qualifier;
};
std::string toString(const SharedPtr &, const std::string &);
} // namespace arti::lang