Skip to content

Commit

Permalink
Merge pull request #23 from DanielVenturini/geração_código
Browse files Browse the repository at this point in the history
Geração código
  • Loading branch information
DanielVenturini authored Dec 7, 2018
2 parents 37d5fce + 93a4fd3 commit 7ca314a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
5 changes: 5 additions & 0 deletions codegenerator/geracao.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "geracao.h"

void geraCodigo(TreeNode *programa, TabSimb *tabela) {
// do somenthing
}
19 changes: 19 additions & 0 deletions codegenerator/geracao.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _GERACAO_H
#define _GERACAO_H

#include "../tree/tree.h"
#include "../semantic/tabsimb.h"

/*-----------------------------*
* BIBLIOTECAS DO LLVM E CLANG *
*-----------------------------*/
#include <llvm-c/BitWriter.h>
#include <llvm-c/Core.h>

/********************************************************************
* DEFINICAO DAS FUNÇÕES *
********************************************************************/

void geraCodigo(TreeNode *, TabSimb *);

#endif
14 changes: 12 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ typedef TokenRecord TR; // apenas para economizar espaços na linha
char **arquivos; // este ponteiro conterá todos os arquivo passados por parâmetros
char flags[8]; // cada posição se refere a um tipo de flag
// flags: [0] = -tk; [1] = -ax; [2] = -at; [3] = -sx; [4] = -st; [5] = -ts; [6] = -h; [7] = -v;
char *version = "4.2.0";

// inves de incluir a biblioteca geracao.h
void geraCodigo(TreeNode *, TabSimb *);

char *version = "4.2.1";

void qualFlag(char *flag) {

Expand Down Expand Up @@ -101,7 +105,7 @@ void printVersion() {
printf("Venturini Compiler Compiler\n");
printf("Release: %s\n", version);
printf("BuildOn: Linux 4.15.0-38-generic\n");
printf("LLVM, Clang and LLI: 3.8.0\n");
printf("LLVM and Clang: 3.5.2\n");
printf("VCC (https://github.com/danielventurini/vcc)\n");
}

Expand Down Expand Up @@ -167,6 +171,12 @@ int main(int argc, char *argv[]) {

if(flags[5])
printEscopo(tabela, 0);

/*******************\
* geração de código *
\*******************/
geraCodigo(ast, tabela);

i ++;
}

Expand Down
26 changes: 22 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
all: main # compila todos os arquivos
install: main clean move xdot highlight # instala o vcc
all: main # compila todos os arquivos
install: main clean move xdot codeinstall highlight # instala o vcc

main: varredura parse semantic # parse já inclui a árvore
gcc main.c lexical/varredura.o tree/tree.o syntactic/parse.o desacerto.o tree/stack.o semantic/poda.o semantic/tabsimb.o semantic/semantico.o -o vcc
# configurações para compilar geracao.c
CC = clang-3.5
CXX = clang++-3.5
LLVMCFG = llvm-config-3.5
OPT = opt-3.5
CFLAGS = -Wall `$(LLVMCFG) --cflags`
LDFLAGS = -Wall `$(LLVMCFG) --libs core --system-libs` `$(LLVMCFG) --ldflags`

# regras do make
# gera todos os arquivos .o e depois linka tudo
main: varredura parse semantic geracao # parse já inclui a árvore
gcc main.c lexical/varredura.o tree/tree.o syntactic/parse.o desacerto.o tree/stack.o semantic/poda.o semantic/tabsimb.o semantic/semantico.o codegenerator/geracao.o -o vcc
make clean

varredura:
Expand All @@ -29,6 +39,9 @@ semantic: poda tabsimb
poda:
gcc -c semantic/poda.c -o semantic/poda.o

geracao:
gcc -c codegenerator/geracao.c -o codegenerator/geracao.o $(CFLAGS)

clean: # apaga os arquivos objetos de compilação
rm lexical/varredura.o -f
rm tree/tree.o -f
Expand All @@ -38,10 +51,15 @@ clean: # apaga os arquivos objetos de compilação
rm semantic/poda.o -f
rm semantic/tabsimb.o -f
rm semantic/semantico.o -f
rm codegenerator/geracao.o -f

xdot: # instala o xdot
apt-get install xdot --allow-unauthenticated -y

codeinstall: # instala llvm e clang, todos na versão 3.5; biblioteca necessária para o -ledit
apt-get install clang-3.5 --allow-unauthenticated -y
sudo apt-get install libedit-dev --allow-unauthenticated -y

move: # move o executavel para a pasta /bin/
mv vcc /usr/bin/

Expand Down

0 comments on commit 7ca314a

Please sign in to comment.