-
Notifications
You must be signed in to change notification settings - Fork 1
/
wnt_LetASTNode.h
66 lines (52 loc) · 1.87 KB
/
wnt_LetASTNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*=====================================================================
LetASTNode.h
------------
Copyright Glare Technologies Limited 2016 -
=====================================================================*/
#pragma once
#include "wnt_ASTNode.h"
#include <string>
namespace Winter
{
/*
In a let block,
like:
let
a = f()
b, c = g()
in
a + b + c
Then 'a = f()' and 'b, c = g()' are nodes of type LetASTNode.
a, b, c individually are LetNodeVars.
*/
class LetNodeVar
{
public:
LetNodeVar() {}
LetNodeVar(const std::string& name_) : name(name_) {}
std::string name;
TypeRef declared_type; // may be NULL
};
class LetASTNode : public ASTNode
{
public:
LetASTNode(const std::vector<LetNodeVar>& vars, const ASTNodeRef& expr, const SrcLocation& loc);
virtual ValueRef exec(VMState& vmstate);
virtual TypeRef type() const { return expr->type(); }
virtual void print(int depth, std::ostream& s) const;
virtual std::string sourceString(int depth) const;
virtual std::string emitOpenCLC(EmitOpenCLCodeParams& params) const;
virtual void traverse(TraversalPayload& payload, std::vector<ASTNode*>& stack);
virtual void updateChild(const ASTNode* old_val, ASTNodeRef& new_val);
virtual llvm::Value* emitLLVMCode(EmitLLVMCodeParams& params, llvm::Value* ret_space_ptr) const;
virtual Reference<ASTNode> clone(CloneMapType& clone_map);
virtual bool isConstant() const;
virtual size_t getTimeBound(GetTimeBoundParams& params) const;
virtual GetSpaceBoundResults getSpaceBound(GetSpaceBoundParams& params) const;
virtual size_t getSubtreeCodeComplexity() const;
ASTNodeRef expr;
std::vector<LetNodeVar> vars; // One or more variable names (And possible associated declared types). Will be more than one in the case of destructuring assignment.
//mutable llvm::Value* llvm_value;
bool traced;
};
} //end namespace Winter