1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00
OpenMW/components/compiler/locals.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
C++
Raw Normal View History

#ifndef COMPILER_LOCALS_H_INCLUDED
#define COMPILER_LOCALS_H_INCLUDED
2022-09-22 18:26:05 +00:00
#include <iosfwd>
#include <string>
2022-05-21 08:48:32 +00:00
#include <string_view>
2022-09-22 18:26:05 +00:00
#include <vector>
namespace Compiler
{
/// \brief Local variable declarations
class Locals
{
2022-09-22 18:26:05 +00:00
std::vector<std::string> mShorts;
std::vector<std::string> mLongs;
std::vector<std::string> mFloats;
2022-09-22 18:26:05 +00:00
std::vector<std::string>& get(char type);
2022-09-22 18:26:05 +00:00
public:
char getType(std::string_view name) const;
///< 's': short, 'l': long, 'f': float, ' ': does not exist.
2022-09-22 18:26:05 +00:00
int getIndex(std::string_view name) const;
///< return index for local variable \a name (-1: does not exist).
2022-09-22 18:26:05 +00:00
bool search(char type, std::string_view name) const;
2022-09-22 18:26:05 +00:00
/// Return index for local variable \a name of type \a type (-1: variable does not
/// exit).
int searchIndex(char type, std::string_view name) const;
2022-09-22 18:26:05 +00:00
const std::vector<std::string>& get(char type) const;
2022-09-22 18:26:05 +00:00
void write(std::ostream& localFile) const;
///< write declarations to file.
2022-09-22 18:26:05 +00:00
void declare(char type, std::string_view name);
///< declares a variable.
2022-09-22 18:26:05 +00:00
void clear();
///< remove all declarations.
};
}
#endif