generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
i_HATE_refactoring
Showing
3 changed files
with
127 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
#include <cmath> | ||
#include <map> | ||
#include <memory> | ||
|
||
#include <llvm/IR/LLVMContext.h> | ||
#include <llvm/IR/Module.h> | ||
#include <llvm/IR/IRBuilder.h> | ||
#include <llvm/IR/Verifier.h> | ||
#include <llvm/IR/Instructions.h> | ||
#include <llvm/IR/Argument.h> | ||
#include <llvm/Support/raw_ostream.h> | ||
#include <llvm/Bitcode/LLVMBitCodes.h> | ||
#include "llvm/IR/DataLayout.h" | ||
#include <llvm/IR/Value.h> | ||
|
||
#include "LLVMController.h" | ||
#include "types.h" | ||
|
||
|
||
types::Value wrapType(llvm::Value* value, llvm::Type* type) { | ||
types::Value v; | ||
v.value = value; | ||
v.type = type; | ||
return v; | ||
} | ||
|
||
types::Value wrapType(llvm::Value* value) { | ||
types::Value v; | ||
v.value = value; | ||
v.type = value->getType(); | ||
return v; | ||
} | ||
|
||
types::PtrValue wrapType(llvm::Value* value, llvm::Type* type, llvm::Type* containedType) { | ||
types::PtrValue v; | ||
v.value = value; | ||
v.type = type; | ||
v.containedType = containedType; | ||
return v; | ||
} | ||
|
||
// unwrap | ||
llvm::Value* unwrap(types::Value v) { | ||
return v.value; | ||
} | ||
|
||
llvm::Value* unwrap(types::PtrValue v) { | ||
return v.value; | ||
} | ||
|
||
// unwrap but return type (contained for pointers) | ||
llvm::Type* unwrapType(types::Value v) { | ||
return v.type; | ||
} | ||
|
||
llvm::Type* unwrapType(types::PtrValue v) { | ||
return v.type; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
#include <cmath> | ||
#include <map> | ||
#include <memory> | ||
|
||
#include <llvm/IR/LLVMContext.h> | ||
#include <llvm/IR/Module.h> | ||
#include <llvm/IR/IRBuilder.h> | ||
#include <llvm/IR/Verifier.h> | ||
#include <llvm/IR/Instructions.h> | ||
#include <llvm/IR/Argument.h> | ||
#include <llvm/Support/raw_ostream.h> | ||
#include <llvm/Bitcode/LLVMBitCodes.h> | ||
#include "llvm/IR/DataLayout.h" | ||
#include <llvm/IR/Value.h> | ||
|
||
#include "LLVMController.h" | ||
|
||
namespace types { | ||
// int, float, bool, char, void, pointers | ||
class Type { | ||
public: | ||
llvm::Type* type; | ||
std::string name; | ||
}; | ||
|
||
class ptr_Type : public Type { | ||
public: | ||
Type* containedType; | ||
}; | ||
|
||
class Value { | ||
public: | ||
llvm::Value* value; | ||
Type* type; | ||
}; | ||
|
||
class PtrValue : public Value { | ||
public: | ||
Type* containedType; | ||
}; | ||
|
||
} | ||
|
||
types::Value wrapType(llvm::Value* value, llvm::Type* type); | ||
types::PtrValue wrapType(llvm::Value* value, llvm::Type* type, llvm::Type* containedType); | ||
types::Value wrapType(llvm::Value* value); |