Skip to content

Commit

Permalink
Remove all traces of the tvm_tree structure.
Browse files Browse the repository at this point in the history
It is to be replaced with a htab hash table.
  • Loading branch information
turnage committed Jan 13, 2014
1 parent b208237 commit ed12ce0
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 148 deletions.
4 changes: 1 addition & 3 deletions include/tvm/tvm_lexer.h
Expand Up @@ -4,8 +4,6 @@
#define MAX_ARGS 2
#define MAX_TOKENS 4

#include "tvm_tree.h"

typedef struct tvm_lexer_s
{
char **source_lines;
Expand All @@ -16,6 +14,6 @@ tvm_lexer_t *lexer_create();
void lexer_destroy(tvm_lexer_t *l);

/* Tokenize the character array "source" into lines and tokens */
void lex(tvm_lexer_t *lexer, char *source, tvm_tree_t **node);
void lex(tvm_lexer_t *lexer, char *source);

#endif
4 changes: 1 addition & 3 deletions include/tvm/tvm_preprocessor.h
@@ -1,8 +1,6 @@
#ifndef TVM_PREPROCESSOR_H_
#define TVM_PREPROCESSOR_H_

#include "tvm_tree.h"

int tvm_preprocess(char *src, int *src_len, tvm_tree_t **node);
int tvm_preprocess(char *src, int *src_len);

#endif
3 changes: 0 additions & 3 deletions include/tvm/tvm_program.h
Expand Up @@ -7,7 +7,6 @@

#include "tvm_htab.h"
#include "tvm_memory.h"
#include "tvm_tree.h"

typedef struct tvm_program_s
{
Expand All @@ -21,8 +20,6 @@ typedef struct tvm_program_s
int **values;
int num_values;

tvm_tree_t *defines;

tvm_htab_t *label_htab;

} tvm_program_t;
Expand Down
17 changes: 0 additions & 17 deletions include/tvm/tvm_tree.h

This file was deleted.

8 changes: 2 additions & 6 deletions libtvm/tvm_lexer.c
Expand Up @@ -26,7 +26,7 @@ void lexer_destroy(tvm_lexer_t *lexer)
free(lexer);
}

void lex(tvm_lexer_t *lexer, char *source, tvm_tree_t **node)
void lex(tvm_lexer_t *lexer, char *source)
{
int i, j;
char *pToken, *pLine = strtok(source, "\n");
Expand Down Expand Up @@ -60,9 +60,7 @@ void lex(tvm_lexer_t *lexer, char *source, tvm_tree_t **node)

for(j = 0; (pToken && j < MAX_TOKENS); j++)
{
/* Check if this token is a define. */
char *token = (char *)tvm_tree_find(*node, pToken);
if(!token) token = pToken;
char *token = pToken;

lexer->tokens[i][j] = (char *)calloc(1, (strlen(token) + 1));
strcpy(lexer->tokens[i][j], token);
Expand All @@ -72,6 +70,4 @@ void lex(tvm_lexer_t *lexer, char *source, tvm_tree_t **node)
}

lexer->tokens[i] = NULL;
tvm_tree_destroy(*node);
*node = NULL;
}
14 changes: 1 addition & 13 deletions libtvm/tvm_preprocessor.c
Expand Up @@ -3,7 +3,7 @@

#include <string.h>

int tvm_preprocess(char *src, int *src_len, tvm_tree_t **node)
int tvm_preprocess(char *src, int *src_len)
{
char* pp_directive_delimiter = NULL;
if((pp_directive_delimiter = strstr(src, "%include")))
Expand Down Expand Up @@ -85,18 +85,6 @@ int tvm_preprocess(char *src, int *src_len, tvm_tree_t **node)
return -1;
}

int err = 0;
if(!*node)
*node = tvm_tree_create(*node, keystr, valstr, strlen(valstr));
else
err = tvm_tree_add(*node, keystr, valstr, strlen(valstr));

if(err == 2)
{
printf("Multiple definitions for %s.\n", keystr);
return -1;
}

/* Remove the define line so it is not processed again. */
size_t new_length = *src_len - (end - begin);
size_t first_block_len = begin - src;
Expand Down
4 changes: 2 additions & 2 deletions libtvm/tvm_program.c
Expand Up @@ -55,14 +55,14 @@ int program_interpret(tvm_program_t *p, char *filename, tvm_memory_t *pMemory)
fclose(pFile);

int err = 0;
while((err = tvm_preprocess(source, &source_length, &p->defines)) > 0);
while((err = tvm_preprocess(source, &source_length)) > 0);

/* The preprocessor encountered a problem. */
if (err < 0)
return 1;

tvm_lexer_t *lexer_ctx = lexer_create();
lex(lexer_ctx, source, &p->defines);
lex(lexer_ctx, source);
free(source);

if(parse_labels(p, (const char ***)lexer_ctx->tokens) != 0) return 1;
Expand Down
101 changes: 0 additions & 101 deletions libtvm/tvm_tree.c

This file was deleted.

0 comments on commit ed12ce0

Please sign in to comment.