Files
BlitzNext/compiler/lib/varnode.hpp
T

69 lines
1.5 KiB
C++
Raw Normal View History

2019-01-19 18:28:07 +01:00
#pragma once
#include <string>
#include "node.hpp"
#include "type.hpp"
2014-01-31 08:23:00 +13:00
2019-01-19 18:28:07 +01:00
class Environ;
class Codegen;
struct TNode;
struct ExprNode;
struct ExprSeqNode;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:57 +01:00
struct VarNode : public Node {
Type* sem_type;
2014-01-31 08:23:00 +13:00
//get set var
2019-01-18 17:04:57 +01:00
TNode* load(Codegen* g);
virtual TNode* store(Codegen* g, TNode* n);
virtual bool isObjParam();
2014-01-31 08:23:00 +13:00
//addr of var
2019-01-18 17:04:57 +01:00
virtual void semant(Environ* e) = 0;
virtual TNode* translate(Codegen* g) = 0;
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct DeclVarNode : public VarNode {
Decl* sem_decl;
2019-01-19 18:28:07 +01:00
DeclVarNode(Decl* d = 0);
2019-01-18 17:04:57 +01:00
void semant(Environ* e);
TNode* translate(Codegen* g);
virtual TNode* store(Codegen* g, TNode* n);
bool isObjParam();
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct IdentVarNode : public DeclVarNode {
2019-01-19 18:28:07 +01:00
std::string ident, tag;
IdentVarNode(const std::string& i, const std::string& t);
2019-01-18 17:04:57 +01:00
void semant(Environ* e);
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct ArrayVarNode : public VarNode {
2019-01-19 18:28:07 +01:00
std::string ident, tag;
2019-01-18 17:04:57 +01:00
ExprSeqNode* exprs;
Decl* sem_decl;
2019-01-19 18:28:07 +01:00
ArrayVarNode(const std::string& i, const std::string& t, ExprSeqNode* e);
~ArrayVarNode();
2019-01-18 17:04:57 +01:00
void semant(Environ* e);
TNode* translate(Codegen* g);
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct FieldVarNode : public VarNode {
2019-01-19 18:28:07 +01:00
ExprNode* expr;
std::string ident, tag;
Decl* sem_field;
FieldVarNode(ExprNode* e, const std::string& i, const std::string& t);
~FieldVarNode();
2019-01-18 17:04:57 +01:00
void semant(Environ* e);
TNode* translate(Codegen* g);
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct VectorVarNode : public VarNode {
ExprNode* expr;
ExprSeqNode* exprs;
VectorType* vec_type;
2019-01-19 18:28:07 +01:00
VectorVarNode(ExprNode* e, ExprSeqNode* es);
~VectorVarNode();
2019-01-18 17:04:57 +01:00
void semant(Environ* e);
TNode* translate(Codegen* g);
2014-01-31 08:23:00 +13:00
};