suppress compiler warnings

This commit is contained in:
Yuichi Nishiwaki 2013-10-20 03:05:42 +09:00
parent 5e96d05fd1
commit daac4dd7f3
7 changed files with 34 additions and 11 deletions

View File

@ -1,10 +1,12 @@
CC=gcc
all: build run
build:
cd src; \
yacc -d parse.y; \
lex scan.l
gcc -Wall -o bin/picrin -I./include -lreadline src/main.c src/state.c src/gc.c src/pair.c src/port.c src/symbol.c src/value.c src/y.tab.c src/lex.yy.c src/bool.c src/vm.c src/init.c src/number.c
$(CC) -Wall -o bin/picrin -I./include -lreadline src/main.c src/state.c src/gc.c src/pair.c src/port.c src/symbol.c src/value.c src/y.tab.c src/lex.yy.c src/bool.c src/vm.c src/init.c src/number.c
clean:
rm -f src/y.tab.c src/y.tab.h src/lex.yy.c

View File

@ -17,13 +17,17 @@ main()
{
pic_state *pic;
char code[CODE_MAX_LENGTH] = "", line[LINE_MAX_LENGTH];
char last_char, *read_line, *prompt;
int char_index;
char *read_line, *prompt;
pic_value v;
struct pic_proc *proc;
int ai;
bool r;
#if ! PIC_ENABLE_READLINE
char last_char;
int char_index;
#endif
pic = pic_open();
ai = pic_gc_arena_preserve(pic);
@ -89,9 +93,11 @@ main()
pic_gc_arena_restore(pic, ai);
}
#if ! PIC_ENABLE_READLINE
eof:
puts("");
goto exit;
#endif
overflow:
puts("** [fatal] line input overflow");

View File

@ -25,7 +25,7 @@ struct parser_control {
%token <datum> tSYMBOL tNUMBER tBOOLEAN
%type <datum> datum simple_datum symbol compound_datum
%type <datum> number list list_data
%type <datum> number boolean list list_data
%%
@ -111,7 +111,7 @@ incomplete_data
%%
int
void
yyerror(struct parser_control *p, const char *msg)
{
puts(msg);

View File

@ -7,11 +7,13 @@
struct parser_control {
pic_state *pic;
pic_value value;
bool incomp;
};
#define YY_DECL int yylex (struct parser_control *p)
%}
%option noinput
%option nounput
/* boolean */

View File

@ -43,7 +43,7 @@ pic_open()
pic->icapa = PIC_IREP_SIZE;
/* globals */
pic->globals = (struct pic_value *)malloc(sizeof(pic_value) * PIC_GLOBALS_SIZE);
pic->globals = (pic_value *)malloc(sizeof(pic_value) * PIC_GLOBALS_SIZE);
pic->glen = 0;
pic->gcapa = PIC_GLOBALS_SIZE;

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include "picrin.h"
#include "picrin/value.h"
enum pic_tt
pic_type(pic_value v)
@ -9,15 +10,18 @@ pic_type(pic_value v)
case PIC_VTYPE_NIL:
return PIC_TT_NIL;
case PIC_VTYPE_TRUE:
return PIC_TT_BOOL;
case PIC_VTYPE_FALSE:
return PIC_TT_BOOL;
case PIC_VTYPE_FLOAT:
return PIC_TT_FLOAT;
case PIC_VTYPE_UNDEF:
return PIC_TT_UNDEF;
case PIC_VTYPE_FLOAT:
return PIC_TT_FLOAT;
case PIC_VTYPE_HEAP:
return ((struct pic_object *)v.u.data)->tt;
}
/* logic flaw (suppress warnings gcc will emit) */
abort();
}
pic_value

View File

@ -143,6 +143,9 @@ print_irep(pic_state *pic, struct pic_irep *irep)
printf("## irep %p [clen = %zd, ccapa = %zd]\n", irep, irep->clen, irep->ccapa);
for (i = 0; i < irep->clen; ++i) {
switch (irep->code[i].insn) {
case OP_POP:
puts("OP_POP");
break;
case OP_PUSHNIL:
puts("OP_PUSHNIL");
break;
@ -375,6 +378,11 @@ pic_gen(pic_state *pic, struct pic_irep *irep, pic_value obj, struct pic_env *en
irep->clen++;
break;
}
case PIC_TT_PROC:
case PIC_TT_UNDEF:
case PIC_TT_PORT: {
pic_raise(pic, "invalid expression given");
}
}
}
@ -431,7 +439,7 @@ pic_gen_lambda(pic_state *pic, pic_value obj, struct pic_env *env)
pic_free(pic, inner_env);
#if VM_DEBUG
printf("LAMBDA_%d:\n", pic->ilen);
printf("LAMBDA_%zd:\n", pic->ilen);
print_irep(pic, irep);
puts("");
#endif
@ -476,6 +484,7 @@ pic_codegen(pic_state *pic, pic_value obj, struct pic_env *env)
#define PUSH(v) (*++pic->sp = (v))
#define POP() (*pic->sp--)
#define POPN(i) ((void)(pic->sp-=i))
#define PUSHCI() (++pic->ci)
#define POPCI() (pic->ci--)
@ -506,7 +515,7 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
VM_LOOP {
CASE(OP_POP) {
POP();
POPN(1);
NEXT;
}
CASE(OP_PUSHNIL) {