diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/ast-tree.c | 20 | ||||
-rw-r--r-- | src/compiler/ast-tree.h | 14 | ||||
-rw-r--r-- | src/compiler/parser.c | 7 | ||||
-rw-r--r-- | src/compiler/parser.h | 4 |
4 files changed, 20 insertions, 25 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index b343cc7..688fc8b 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -1395,8 +1395,7 @@ AstTreeVariables copyAstTreeVariables(AstTreeVariables variables, AstTreeRoots makeAstTree(const char *filePath #ifdef PRINT_STATISTICS , - struct timespec *lexingTime, - struct timespec *parsingTime + Time *lexingTime, Time *parsingTime #endif ) { AstTreeRoots roots = { @@ -1425,8 +1424,7 @@ RETURN_ERROR: AstTreeRoot *getAstTreeRoot(char *filePath, AstTreeRoots *roots #ifdef PRINT_STATISTICS , - struct timespec *lexingTime, - struct timespec *parsingTime + Time *lexingTime, Time *parsingTime #endif ) { for (size_t i = 0; i < roots->size; ++i) { @@ -1436,15 +1434,14 @@ AstTreeRoot *getAstTreeRoot(char *filePath, AstTreeRoots *roots } } - struct timespec start, end; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); + Time start = get_time(); ParserNode *parserNode = parserFromPath(filePath, lexingTime); if (parserNode == NULL) { goto RETURN_ERROR; } - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); + Time end = get_time(); *parsingTime = time_add(*parsingTime, time_diff(end, start)); AstTreeRoot *root = makeAstRoot(parserNode, filePath); parserNodeDelete(parserNode); @@ -2016,7 +2013,7 @@ AstTree *astTreeParse(const ParserNode *parserNode, AstTreeHelper *helper) { case PARSER_TOKEN_KEYWORD_UNDEFINED: return astTreeParseKeyword(parserNode, AST_TREE_TOKEN_VALUE_UNDEFINED); case PARSER_TOKEN_KEYWORD_PUTC: - return astTreeParsePrintU64(parserNode, helper); + return astTreeParsePutc(parserNode, helper); case PARSER_TOKEN_KEYWORD_RETURN: return astTreeParseReturn(parserNode, helper); case PARSER_TOKEN_OPERATOR_ASSIGN: @@ -2528,8 +2525,7 @@ AstTree *astTreeParseKeyword(const ParserNode *parserNode, AstTreeToken token) { parserNode->str_end); } -AstTree *astTreeParsePrintU64(const ParserNode *parserNode, - AstTreeHelper *helper) { +AstTree *astTreeParsePutc(const ParserNode *parserNode, AstTreeHelper *helper) { ParserNodeSingleChildMetadata *node_metadata = parserNode->metadata; AstTree *operand = astTreeParse(node_metadata, helper); @@ -4089,7 +4085,7 @@ bool setAllTypes(AstTree *tree, AstTreeSetTypesHelper helper, case AST_TREE_TOKEN_FUNCTION: return setTypesFunction(tree, helper); case AST_TREE_TOKEN_KEYWORD_PUTC: - return setTypesPrintU64(tree, helper); + return setTypesPutc(tree, helper); case AST_TREE_TOKEN_KEYWORD_RETURN: return setTypesReturn(tree, helper, function); case AST_TREE_TOKEN_TYPE_FUNCTION: @@ -4465,7 +4461,7 @@ bool setTypesFunction(AstTree *tree, AstTreeSetTypesHelper _helper) { return true; } -bool setTypesPrintU64(AstTree *tree, AstTreeSetTypesHelper _helper) { +bool setTypesPutc(AstTree *tree, AstTreeSetTypesHelper _helper) { AstTreeSingleChild *metadata = tree->metadata; AstTreeSetTypesHelper helper = { .lookingType = &AST_TREE_U8_TYPE, diff --git a/src/compiler/ast-tree.h b/src/compiler/ast-tree.h index bd357d2..c1f0464 100644 --- a/src/compiler/ast-tree.h +++ b/src/compiler/ast-tree.h @@ -1,7 +1,7 @@ #pragma once #include "compiler/parser.h" -#include <time.h> +#include "utils/time.h" typedef enum AstTreeToken { AST_TREE_TOKEN_FUNCTION, @@ -312,15 +312,15 @@ AstTreeVariables copyAstTreeVariables(AstTreeVariables variables, AstTreeRoots makeAstTree(const char *filePath #ifdef PRINT_STATISTICS , - struct timespec *lexingTime, - struct timespec *parsingTime + Time *lexingTime, + Time *parsingTime #endif ); AstTreeRoot *getAstTreeRoot(char *filePath, AstTreeRoots *roots #ifdef PRINT_STATISTICS , - struct timespec *lexingTime, - struct timespec *parsingTime + Time *lexingTime, + Time *parsingTime #endif ); AstTreeRoot *makeAstRoot(const ParserNode *parsedRoot, char *filePath); @@ -342,7 +342,7 @@ AstTree *astTreeParseValue(const ParserNode *parserNode, AstTreeToken token, AstTree *astTreeParseString(const ParserNode *parserNode, AstTreeHelper *helper); AstTree *astTreeParseKeyword(const ParserNode *parserNode, AstTreeToken token); -AstTree *astTreeParsePrintU64(const ParserNode *parserNode, +AstTree *astTreeParsePutc(const ParserNode *parserNode, AstTreeHelper *helper); AstTree *astTreeParseReturn(const ParserNode *parserNode, AstTreeHelper *helper); @@ -396,7 +396,7 @@ bool setTypesValueNull(AstTree *tree, AstTreeSetTypesHelper helper); bool setTypesValueUndefined(AstTree *tree, AstTreeSetTypesHelper helper); bool setTypesValueObject(AstTree *tree, AstTreeSetTypesHelper helper); bool setTypesFunction(AstTree *tree, AstTreeSetTypesHelper helper); -bool setTypesPrintU64(AstTree *tree, AstTreeSetTypesHelper helper); +bool setTypesPutc(AstTree *tree, AstTreeSetTypesHelper helper); bool setTypesReturn(AstTree *tree, AstTreeSetTypesHelper helper, AstTreeFunction *function); bool setTypesTypeFunction(AstTree *tree, AstTreeSetTypesHelper helper); diff --git a/src/compiler/parser.c b/src/compiler/parser.c index 7bb0f1d..388e69a 100644 --- a/src/compiler/parser.c +++ b/src/compiler/parser.c @@ -731,11 +731,10 @@ ParserNode *newParserNode(ParserToken token, char const *str_begin, ParserNode *parserFromPath(const char *filePath #ifdef PRINT_STATISTICS , - struct timespec *lexingTime + Time *lexingTime #endif ) { - struct timespec start, end; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); + Time start = get_time(); char *code = readWholeFile(filePath); if (code == NULL) { return NULL; @@ -745,7 +744,7 @@ ParserNode *parserFromPath(const char *filePath if (lexerNodeArrayIsError(lexed)) { return NULL; } - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); + Time end = get_time(); *lexingTime = time_add(*lexingTime, time_diff(end, start)); ParserNode *root = parser(lexed); diff --git a/src/compiler/parser.h b/src/compiler/parser.h index 05409fb..0e43c34 100644 --- a/src/compiler/parser.h +++ b/src/compiler/parser.h @@ -1,8 +1,8 @@ #pragma once #include "compiler/lexer.h" +#include "utils/time.h" #include "utils/type.h" -#include <time.h> typedef enum ParserToken { PARSER_TOKEN_ROOT, @@ -200,7 +200,7 @@ void parserNodeDelete(ParserNode *node); ParserNode *parserFromPath(const char *filePath #ifdef PRINT_STATISTICS , - struct timespec *lexingTime + Time *lexingTime #endif ); ParserNode *parser(LexerNodeArray lexed); |