Initial work for functions as values. Actually works, but you can't write out the type and thus can only declare function pointer variables with type inference.
This commit is contained in:
@@ -43,6 +43,7 @@ class ASTTransformation: public NodeTransformation<Symbol,ASTData> {
|
||||
NodeTree<ASTData>* transform(NodeTree<Symbol>* from, NodeTree<ASTData>* scope, std::vector<Type> types, std::map<std::string, Type*> templateTypeReplacements);
|
||||
std::vector<NodeTree<ASTData>*> transformChildren(std::vector<NodeTree<Symbol>*> children, std::set<int> skipChildren, NodeTree<ASTData>* scope, std::vector<Type> types, std::map<std::string, Type*> templateTypeReplacements);
|
||||
std::vector<Type> mapNodesToTypes(std::vector<NodeTree<ASTData>*> nodes);
|
||||
std::vector<Type*> mapNodesToTypePointers(std::vector<NodeTree<ASTData>*> nodes);
|
||||
std::string concatSymbolTree(NodeTree<Symbol>* root);
|
||||
NodeTree<ASTData>* doFunction(NodeTree<ASTData>* scope, std::string lookup, std::vector<NodeTree<ASTData>*> nodes, std::map<std::string, Type*> templateTypeReplacements);
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ class CGenerator {
|
||||
bool isUnderTranslationUnit(NodeTree<ASTData>* from, NodeTree<ASTData>* typeDefinition);
|
||||
NodeTree<ASTData>* highestScope(NodeTree<ASTData>* node);
|
||||
std::pair<std::string, std::string> generateTranslationUnit(std::string name, std::map<std::string, NodeTree<ASTData>*> ASTs);
|
||||
std::string generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enclosingObject = NULL);
|
||||
std::string generate(NodeTree<ASTData>* from, NodeTree<ASTData>* enclosingObject = NULL, bool justFuncName = false);
|
||||
std::string generateAliasChains(std::map<std::string, NodeTree<ASTData>*> ASTs, NodeTree<ASTData>* definition);
|
||||
static std::string ValueTypeToCType(Type *type);
|
||||
static std::string ValueTypeToCType(Type *type, std::string);
|
||||
static std::string ValueTypeToCTypeDecoration(Type *type);
|
||||
static std::string ValueTypeToCTypeThingHelper(Type *type, std::string ptrStr);
|
||||
static std::string CifyName(std::string name);
|
||||
|
||||
@@ -14,7 +14,7 @@ class ASTData;
|
||||
#include "ASTData.h"
|
||||
#include "util.h"
|
||||
|
||||
enum ValueType {none, template_type, template_type_type, void_type, boolean, integer, floating, double_percision, character };
|
||||
enum ValueType {none, template_type, template_type_type, void_type, boolean, integer, floating, double_percision, character, function_type };
|
||||
|
||||
|
||||
class Type {
|
||||
@@ -25,6 +25,8 @@ class Type {
|
||||
Type(NodeTree<ASTData>* typeDefinitionIn, int indirectionIn = 0);
|
||||
Type(NodeTree<ASTData>* typeDefinitionIn, std::set<std::string> traitsIn);
|
||||
Type(ValueType typeIn, NodeTree<ASTData>* typeDefinitionIn, int indirectionIn, std::set<std::string> traitsIn);
|
||||
Type(ValueType typeIn, NodeTree<ASTData>* typeDefinitionIn, int indirectionIn, std::set<std::string> traitsIn, std::vector<Type*> parameterTypesIn, Type* returnTypeIn);
|
||||
Type(std::vector<Type*> parameterTypesIn, Type* returnTypeIn);
|
||||
Type(ValueType typeIn, NodeTree<Symbol>* templateDefinitionIn, std::set<std::string> traitsIn = std::set<std::string>());
|
||||
~Type();
|
||||
bool const operator==(const Type &other)const;
|
||||
@@ -42,6 +44,8 @@ class Type {
|
||||
NodeTree<Symbol>* templateDefinition;
|
||||
std::map<std::string, Type*> templateTypeReplacement;
|
||||
std::set<std::string> traits;
|
||||
std::vector<Type*> parameterTypes;
|
||||
Type *returnType;
|
||||
private:
|
||||
int indirection;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user