tagged release 0.7.1
[parrot.git] / compilers / pirc / new / pircompiler.h
blob5f493db1103ce53cc5b137808a2c83264166edb9
1 /*
2 * $Id$
3 * Copyright (C) 2007-2008, The Perl Foundation.
4 */
6 #ifndef PARROT_PIR_PIRCOMPILER_H_GUARD
7 #define PARROT_PIR_PIRCOMPILER_H_GUARD
9 #include "pirsymbol.h"
10 #include "pircompunit.h"
13 #include "parrot/parrot.h"
14 #include "parrot/embed.h"
17 #include <stdio.h> /* for FILE * */
20 /* a cache stores can store objects to reuse; for now, only for invocation objects */
21 typedef struct cache {
22 invocation inv_cache;
23 PMC *str_cache;
25 } cache;
29 /* store the "globals" of the lexer in a structure which is passed around. */
30 typedef struct lexer_state {
31 int parse_errors;
32 char *filename; /* name of input file */
33 FILE *outfile; /* name of output file */
35 subroutine *subs; /* list of subs; always points to the current sub. */
37 key *current_ns; /* keeps track of namespace */
39 target *curtarget; /* access to current target node being parsed, if any */
40 argument *curarg; /* access to current argument node being parsed, if any */
42 int curregister[4]; /* for register allocation */
43 int pir_reg_generator; /* for unique PIR register allocator, for temp. PIR regs. */
45 global_ident *globals; /* global identifiers */
46 constant *constants; /* global constants */
48 Interp *interp; /* parrot interpreter */
50 cache obj_cache; /* cache for all sorts of objects to save memory allocations */
52 } lexer_state;
56 /* constructor for a lexer_state object */
57 lexer_state *new_lexer(char * const filename);
59 void pirerror(lexer_state * const lexer, char const * const message, ...);
61 void release_resources(lexer_state *lexer);
63 char *dupstr(lexer_state * const lexer, char * str);
64 char *dupstrn(lexer_state * const lexer, char * str, size_t numchars);
66 #endif /* PARROT_PIR_PIRCOMPILER_H_GUARD */
69 * Local variables:
70 * c-file-style: "parrot"
71 * End:
72 * vim: expandtab shiftwidth=4: