35 void const_violation();
41 operator bool()
const {
return e; }
45 return prot && strcmp(prot->
key, e->
key) == 0 && !prot->
val;
51 prot->
key = strdup(e->
key);
67 freeset(e->
val, nulldup(val));
77 int Index(
const char *key)
const;
79 const hash_entry *find_entry(
const char *key,
int idx)
const;
80 hash_entry *find_entry(
const char *key,
int idx) {
81 return const_cast<hash_entry*
>(
const_cast<const hash*
>(
this)->find_entry(key, idx));
91 const char *
read(
const char *key)
const {
return ref(key).
read(); }
92 void write(
const char *key,
const char *val);
99 T *new_ptr = (
T*)realloc(ptr, new_size);
102 throw "out of memory";
136 if (c == ALIGN_MARKER) ++markers;
156 for (
int i = 0; i<count; ++i) freenull(queue[i]);
163 queue((
char**)malloc(size*sizeof(*queue)))
170 bool empty()
const {
return count == 0; }
179 queue[count++] =
line;
185 for (
int i = 0; i<count; ++i) {
186 fputs(queue[i], out);
204 void outputchar(
char c) {
208 void print_char(
char c) {
209 if (!printed_sth && (indent || column)) {
210 int ipos = indent*tabstop + column;
211 for (
int i = 0; i<ipos; ++i) outputchar(
' ');
218 void tab_to_pos(
int pos) {
221 while (column < pos) {
240 toAlign.
add(currentLine.
take());
254 for (
int i = 0; i <= 9; i++) {
285 bool wasOpened()
const {
return fp && name; }
290 if (have_open_loc && terminating) {
301 void reuse() {
cleanup(); setup(); }
305 Output() { terminating =
false; setup(); }
310 void assign(FILE *fp_,
const char *id_,
const char *name_,
const Location *openedAt) {
316 name = strdup(name_);
318 have_open_loc = openedAt;
319 if (openedAt) open_loc = *openedAt;
321 void assign(FILE *fp_,
const char *id_,
const char *name_) {
324 void assign(FILE *fp_,
const char *id_,
const char *name_,
const Code *openedAt_) {
338 fprintf(stderr,
"Unlinking %s\n", name);
345 bool hasID(
const char *Name)
const {
return id && strcmp(
id, Name) == 0; }
405 static const int MAX_COMMANDS = 32;
407 void command_table_setup(
bool setup);
411 Output *find_output_for_ID(
const char *fileID) {
414 if (output[i].hasID(fileID))
return &output[i];
421 void write_var(
const char *name,
const char *val) { stack->
hs->
write(name, val); }
422 const char *read_var(
const char *name) {
return stack->
hs->
read(name); }
424 void define_fun(
const char *name,
const Code *co);
425 const Code *find_fun(
const char *name);
429 void jump(
const Code *to) { nextpc = to; }
431 int do_close(
const char *
str);
432 int do_create(
const char *str);
433 int do_data(
const char *str);
434 int do_dumpdata(
const char *filename);
435 int do_error(
const char *str) {
print_error(
at(), str);
return 1; }
436 int do_exit() { nextpc =
NULp;
return 0; }
437 int do_for(
const char *str);
438 int do_gosub(
const char *str);
439 int do_goto(
const char *str);
440 int do_if(
const char *str);
441 int do_moveto(
const char *str);
443 int do_open(
const char *str);
444 int do_out(
const char *str);
448 int do_set(
const char *str);
449 int do_makeconst(
const char *str);
450 int do_tab(
const char *str);
451 int do_tabstop(
const char *str);
453 int do_warning(
const char *str) {
print_warning(
at(), str);
return 0; }
455 int do_write_current(
const char *str) {
return current_output->
write(str); }
456 int do_newline() {
return current_output->
write(
""); }
457 int do_write_stdout(
const char *str) {
return output[0].
write(str); }
459 int do_write_maybe_start() { current_output->
maybe_start();
return 0; }
460 int do_write_maybe(
const char *str) {
return current_output->
maybe_write(str); }
461 int do_write_maybe_end() {
return current_output->
maybe_end(); }
463 int compile_program();
466 bool set_data(
const char *filename,
int offset_in_line);
476 command_table_setup(
true);
486 current_output = &output[0];
500 command_table_setup(
false);
504 int launch(
int argc,
char ** argv);
510 const char *
read_local(
const char *key)
const;
515 #error aisc.h included twice
void set_cursor(const Token *newCursor)
int write(const char *line)
void do_indent(ostream &out, int indent)
bool write_protected() const
#define ASSERT_RESULT(Type, Expected, Expr)
static const Interpreter * instance
void write(const char *key, const char *val)
int write(const char *val) __ATTR__USERESULT
const Token * get_cursor() const
var_ref ref(const char *key)
const Token * find_token(const Token *curs, const char *str, LookupScope scope) const
var_ref get_local(const char *key)
void alignInto(LineQueue &dest)
void realloc_unleaked(T *&ptr, size_t new_size)
#define print_error(code_or_loc, err)
void set_tokens(TokenListBlock *newRoot)
static const Location & guess_pc()
void assign_stdout(const char *id_)
const char * read(const char *key) const
fputs(TRACE_PREFIX, stderr)
int maybe_write(const char *line)
#define __ATTR__USERESULT
const char * read() const
void assign(FILE *fp_, const char *id_, const char *name_)
const Data & get_data() const
const var_ref ref(const char *key) const
bool needsAlignment() const
static const int LINEBUFSIZE
int launch(int argc, char **argv)
void assign(FILE *fp_, const char *id_, const char *name_, const Code *openedAt_)
const char * read_local(const char *key) const
Formatter & get_formatter()
const TokenListBlock * get_tokens() const
void dump_cursor_pos(FILE *out) const
#define aisc_assert(cond)
bool hasID(const char *Name) const
#define print_warning(code_or_loc, err)
static const char ALIGN_MARKER
const Token * find_qualified_token(const char *str, LookupScope scope) const
void assign(FILE *fp_, const char *id_, const char *name_, const Location *openedAt)
const Location & pc() const