Пример #1
0
 static void calculate_labels( label_map& out_labels, const std::uint32_t address, const label& lab, const Tail&... tail )
 {
   if( !out_labels.insert( { lab.name, address } ).second )
   {
     throw std::logic_error( "Duplicate label " + lab.name );
   }
   calculate_labels( out_labels, address, tail... );
 }
Пример #2
0
 static void calculate_labels( label_map& out_labels, const std::uint32_t address, const Head& head, const Tail&... tail )
 {
   perseus::detail::code_segment::size_type size = 0;
   {
     // to get the correct size even in case of opcode encoding etc.
     perseus::detail::code_segment code;
     code.push< Head >( head );
     size = code.size();
   }
   calculate_labels( out_labels, address + size, tail... );
 }
Пример #3
0
void gsl_compile(GoomSL *_currentGoomSL, const char *script)
{ /* {{{ */
  char *script_and_externals;
  static const char *sBinds =
    "external <charAt: string value, int index> : int\n"
    "external <f2i: float value> : int\n"
    "external <i2f: int value> : float\n";

#ifdef VERBOSE
  printf("\n=== Starting Compilation ===\n");
#endif

  script_and_externals = malloc(strlen(script) + strlen(sBinds) + 2);
  strcpy(script_and_externals, sBinds);
  strcat(script_and_externals, script);

  /* 0- reset */
  currentGoomSL = _currentGoomSL;
  reset_scanner(currentGoomSL);

  /* 1- create the syntaxic tree */
  yy_scan_string(script_and_externals);
  yyparse();

  /* 2- generate code */
  gsl_commit_compilation();

  /* 3- resolve symbols */
  calculate_labels(currentGoomSL->iflow);

  /* 4- optimize code */
  gsl_create_fast_iflow();

  /* 5- bind a few internal functions */
  gsl_bind_function(currentGoomSL, "charAt", ext_charAt);
  gsl_bind_function(currentGoomSL, "f2i", ext_f2i);
  gsl_bind_function(currentGoomSL, "i2f", ext_i2f);
  free(script_and_externals);
  
#ifdef VERBOSE
  printf("=== Compilation done. # of lines: %d. # of instr: %d ===\n", currentGoomSL->num_lines, currentGoomSL->iflow->number);
#endif
} /* }}} */
Пример #4
0
 static void calculate_labels( label_map& out_labels, const std::uint32_t address, const label_reference_offset& reference, const Tail&... tail )
 {
   calculate_labels( out_labels, address + sizeof( std::uint32_t ), tail... );
 }
Пример #5
0
 static void calculate_labels( label_map& out_labels, const std::uint32_t address, const get_current_address& retriever, const Tail&... tail )
 {
   calculate_labels( out_labels, address, tail... );
 }