Files
BlitzNext/compiler/varnode.hpp
T

82 lines
1.7 KiB
C++
Raw Normal View History

2014-01-31 08:23:00 +13:00
#ifndef VARNODE_H
#define VARNODE_H
2019-01-18 15:55:51 +01:00
#include "varnode.hpp"
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 15:55:51 +01:00
#include "decl.hpp"
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:57 +01:00
struct DeclVarNode : public VarNode {
Decl* sem_decl;
DeclVarNode(Decl* d = 0) : sem_decl(d)
{
if (d)
sem_type = d->type;
}
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 {
string ident, tag;
IdentVarNode(const string& i, const string& t) : ident(i), tag(t) {}
void semant(Environ* e);
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:57 +01:00
struct ArrayVarNode : public VarNode {
string ident, tag;
ExprSeqNode* exprs;
Decl* sem_decl;
ArrayVarNode(const string& i, const string& t, ExprSeqNode* e) : ident(i), tag(t), exprs(e) {}
~ArrayVarNode()
{
delete exprs;
}
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 {
ExprNode* expr;
string ident, tag;
Decl* sem_field;
FieldVarNode(ExprNode* e, const string& i, const string& t) : expr(e), ident(i), tag(t) {}
~FieldVarNode()
{
delete expr;
}
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;
VectorVarNode(ExprNode* e, ExprSeqNode* es) : expr(e), exprs(es) {}
~VectorVarNode()
{
delete expr;
delete exprs;
}
void semant(Environ* e);
TNode* translate(Codegen* g);
2014-01-31 08:23:00 +13:00
};
#endif