Skip to content

Commit

Permalink
add a few splint annotations. Need to find other annotations that are…
Browse files Browse the repository at this point in the history
… applicable and annotate rest of source.
  • Loading branch information
kjs committed Jun 13, 2012
1 parent be0a7b1 commit 1fdc321
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/ann.h
@@ -1,6 +1,17 @@
/*
Splint annotations.
*/

#ifndef __M1_ANN_H__
#define __M1_ANN_H__

#define NOTNULL(x) /*@notnull@*/ x

#define NOTNULL(x) /*@notnull@*/ x
#define ARGOUT(x) /*@out@*/ x
#define ARGIN(x) /*@in@*/ x

#define ARGIN_NOTNULL(x) /*@notnull@*/ /*@in@*/ x

#endif
8 changes: 4 additions & 4 deletions src/ast.c
Expand Up @@ -33,9 +33,9 @@ m1_malloc(size_t size) {
}


/*@modiefies nothing @*/

m1_chunk *
chunk(M1_compiler *comp, char *rettype, NOTNULL(char *name)) {
chunk(ARGIN_NOTNULL(M1_compiler *comp), ARGIN(char *rettype), ARGIN_NOTNULL(char *name)) {
m1_chunk *c = (m1_chunk *)m1_malloc(sizeof(m1_chunk));
c->rettype = rettype;
c->name = name;
Expand All @@ -53,15 +53,15 @@ chunk(M1_compiler *comp, char *rettype, NOTNULL(char *name)) {
}

m1_expression *
block(M1_compiler *comp) {
block(ARGIN_NOTNULL(M1_compiler *comp)) {
m1_expression *expr = expression(comp, EXPR_BLOCK);
expr->expr.blck = (m1_block *)m1_malloc(sizeof(m1_block));
init_symtab(&expr->expr.blck->locals);
return expr;
}

void
block_set_stat(m1_expression *block, m1_expression *stat) {
block_set_stat(ARGIN(m1_expression *block), m1_expression *stat) {
block->expr.blck->stats = stat;
}

Expand Down
10 changes: 8 additions & 2 deletions src/ast.h
Expand Up @@ -6,6 +6,8 @@
#include "instr.h"
#include "compiler.h"

#include "ann.h"


typedef struct m1_block {
struct m1_expression *stats;
Expand Down Expand Up @@ -320,7 +322,11 @@ typedef struct m1_expression {

extern int yyget_lineno(yyscan_t yyscanner);

extern m1_chunk *chunk(M1_compiler *comp, char *rettype, char *name);
//extern m1_chunk *chunk(M1_compiler *comp, char *rettype, char *name);
extern m1_chunk *chunk(ARGIN_NOTNULL(M1_compiler *comp), ARGIN(char *rettype), ARGIN_NOTNULL(char *name));

//extern m1_expression *block(M1_compiler *comp);
extern m1_expression *block(ARGIN_NOTNULL(M1_compiler *comp));

extern m1_expression *expression(M1_compiler *comp, m1_expr_type type);
extern m1_expression *funcall(M1_compiler *comp, m1_object *fun, m1_expression *args);
Expand Down Expand Up @@ -379,7 +385,7 @@ extern m1_enum *newenum(M1_compiler *comp, char *name, m1_enumconst *enumconstan

extern m1_var *parameter(M1_compiler *comp, char *type, char *name);

extern m1_expression *block(M1_compiler *comp);

extern void block_set_stat(m1_expression *block, m1_expression *stat);

extern struct m1_expression *open_scope(M1_compiler *comp);
Expand Down

0 comments on commit 1fdc321

Please sign in to comment.