aboutsummaryrefslogtreecommitdiff
path: root/src/generator.h
blob: 825ec8c3304219d78be16527329f06422c7266f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
 * UPEM / Compilation / Projet
 * Pacien TRAN-GIRARD, Adam NAILI
 */

#ifndef __GENERATOR_H__
#define __GENERATOR_H__

#include <stdio.h>

typedef enum scope {
  GLOBAL,
  LOCAL
} Scope;

extern int nb_globals;
FILE *output;

void gen_prologue();
void gen_prologue_continue();
void gen_const_declaration();
void gen_declaration(const char name[], int type, Scope scope);

void gen_read(const char name[], Scope scope);
void gen_print();

void gen_if_label(int idx);
void gen_if_start(int idx);
void gen_if_end(int idx);
void gen_ifelse_end(int idx);

int gen_assign(const char ident[], Scope scope);
void gen_or(int left, int right, int idx);
void gen_and(int left, int right, int idx);
void gen_eq(const char op[], int left, int right, int idx);
void gen_order(const char op[], int left, int right, int idx);
void gen_addsub(char op, int left, int right);
void gen_divstar(char op, int left, int right);

int gen_signed_expr(char op, int type);
int gen_negate_expr(int type);
int gen_value(const char ident[], Scope scope);
int gen_num(int value, Scope scope);
int gen_char(int value, Scope scope);

#endif