Brain  1.0.0
A fast esoteric language!
LoopExpr.h
1 /* This is the source code of Brain Programming Language.
2  * It is licensed under GNU GPL v. 3 or later.
3  * You should have received a copy of the license in this archive (see LICENSE).
4  *
5  * Copyright Brain, 2016.
6  */
7 
8 #ifndef LOOP_EXPR_H
9 #define LOOP_EXPR_H
10 
11 #include <llvm/IR/IRBuilder.h>
12 #include <llvm/IR/Module.h>
13 
14 #include <vector>
15 #include <iostream>
16 
17 #include "Expr.h"
18 
22 typedef enum
23 {
24  LT_WHILE,
25  LT_FOR
26 } LoopType;
27 
28 
32 class LoopExpr : public Expr
33 {
34 protected:
35  std::vector<Expr *> _exprs;
36  LoopType _type;
37 public:
38  LoopExpr(std::vector<Expr *> exprs, LoopType type) : _exprs(exprs),
39  _type(type) {}
40  ~LoopExpr() {}
48  void code_gen(llvm::Module *M, llvm::IRBuilder<> &B,
49  llvm::BasicBlock *BreakBB);
56  void debug_description(int level);
61  void ast_code_gen();
62 };
63 
64 #endif // LOOP_EXPR_H
Abstract class in which all expressions in Brain implement from.
Definition: Expr.h:62
Class that represents the loop operator in Brain.
Definition: LoopExpr.h:32
void code_gen(llvm::Module *M, llvm::IRBuilder<> &B, llvm::BasicBlock *BreakBB)
Generates the IR (Intermediate Representation) code to be executed by llvm.
Definition: LoopExpr.cpp:11
void debug_description(int level)
Prints debug information when Brain&#39;s compiler has the active flags: -v | -emit-ast.
Definition: LoopExpr.cpp:88
void ast_code_gen()
Method for the reverse code generation from the AST. It prints out to the stdout the token itself...
Definition: LoopExpr.cpp:119