-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from alexdovzhanyn/function-closures
Indirect function calls
- Loading branch information
Showing
45 changed files
with
1,733 additions
and
402 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,30 @@ | ||
#pragma once | ||
|
||
#include "binaryen-c.h" | ||
|
||
namespace Theta { | ||
class FunctionMetaData { | ||
public: | ||
FunctionMetaData( | ||
int totalParams, | ||
BinaryenType* paramTypes, | ||
BinaryenType resultType | ||
) : arity(totalParams), params(paramTypes), returnType(resultType) { | ||
paramType = BinaryenTypeCreate(params, arity); | ||
}; | ||
|
||
int getArity() { return arity; } | ||
|
||
BinaryenType* getParams() { return params; } | ||
|
||
BinaryenType getParamType() { return paramType; } | ||
|
||
BinaryenType getReturnType() { return returnType; } | ||
|
||
private: | ||
int arity; | ||
BinaryenType* params; | ||
BinaryenType paramType; | ||
BinaryenType returnType; | ||
}; | ||
} |
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,23 @@ | ||
|
||
|
||
namespace Theta { | ||
enum PointerType { | ||
Function, | ||
Closure, | ||
Data | ||
}; | ||
|
||
template<PointerType type> | ||
class Pointer { | ||
public: | ||
Pointer() : address(-1) {} | ||
Pointer(int addr) : address(addr) {} | ||
|
||
PointerType getType() { return type; } | ||
|
||
int getAddress() { return address; } | ||
|
||
private: | ||
int address; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include "../parser/ast/TypeDeclarationNode.hpp" | ||
#include "parser/ast/ASTNode.hpp" | ||
#include <map> | ||
using namespace std; | ||
|
||
namespace Theta { | ||
template<typename T> | ||
class SymbolTable { | ||
public: | ||
void insert(const string &name, shared_ptr<ASTNode> type) { | ||
table[name] = type; | ||
void insert(const string &name, T value) { | ||
table[name] = value; | ||
} | ||
|
||
shared_ptr<ASTNode> lookup(const string &name) { | ||
optional<T> lookup(const string &name) { | ||
auto it = table.find(name); | ||
|
||
if (it != table.end()) return it->second; | ||
|
||
return nullptr; | ||
return nullopt; | ||
} | ||
|
||
private: | ||
map<string, shared_ptr<ASTNode>> table; | ||
map<string, T> table; | ||
}; | ||
} |
Oops, something went wrong.