Пример #1
0
_symbol *update_table (char *symbol)
{
    unsigned int index;
    _symbol *entry;

    index = hash(symbol);
    entry = look_up_symbol(symbol, index);
    if (entry == NULL) {
	entry = write_symbol(symbol, SYMBOL, index);
	push_symbol(entry);
    }
    return entry;
}
Пример #2
0
void set_local_vars(char *functor)
{
  int total_locals;
  int index = look_up_symbol(functor);
  total_locals = (cur_counter - 1) - index - table[index].total_args;

  table[index].total_locals = total_locals;

  for (int j = total_locals, i = cur_counter - 1; j > 0; i--, j--) {
    table[i].scope = cur_scope;
    table[i].offset = j;
    table[i].mode = LOCAL_MODE;
  }
}
Пример #3
0
void set_scope_and_offset_of_param(char *s)
{
  int total_args;
  int index = look_up_symbol(s);
  if (index < 0) perror("Error in function header");
  else {
    table[index].type = T_FUNCTION;
    total_args = cur_counter - index - 1;
    table[index].total_args = total_args;
    for (int j = total_args, i = cur_counter - 1; i > index; i--, j--) {
      table[i].scope = cur_scope;
      table[i].offset = j + 2; // Const for local_var counts
      table[i].mode = ARGUMENT_MODE;
      fprintf(f_asm, "  swi   $r%d, [$fp + (-%d)]\n", j - 1, table[i].offset * 4 + 8);
    }
  }
}