summary refs log tree commit diff stats
path: root/compiler/semcall.nim
Commit message (Collapse)AuthorAgeFilesLines
* Converter bug fixes (#9700)cooldome2018-11-151-0/+2
| | | | | * Fixes #9698 * Fixes #9699
* added first version of a nimfind tool for the poor souls that don't have a ↵Andreas Rumpf2018-11-141-2/+2
| | | | good nimsuggest integretation
* feedback injectedArne Döring2018-11-081-1/+2
|
* fix #9319Arne Döring2018-11-081-0/+2
|
* produce more helpful error messages when overloading resolution failsAndreas Rumpf2018-11-031-8/+12
|
* replace deprecated `safeAdd` with `add` (#9416)Miran2018-10-181-1/+1
|
* fixes #8671; show helpful msg (lookup symbol, eg iterator) on 'attempting to ↵Timothee Cour2018-10-141-5/+27
| | | | call undeclared routine' error (#8786)
* Fix overload resolution for pragmas evaluation (#8902)LemonBoy2018-10-091-6/+7
| | | | Fixes #6448 Fixes #4384
* fixes #8043Araq2018-09-031-4/+7
|
* show all mismatching overloads againAraq2018-08-271-9/+11
|
* improve the error message for mutability problems that arise from implicit ↵Araq2018-08-271-1/+3
| | | | converter calls
* improve error messages by filtering out highly unlikely mismatchesAndreas Rumpf2018-08-241-0/+10
|
* Update all the default parameters after an instantiation (#8689)LemonBoy2018-08-201-6/+5
| | | | | | The old implementation relied on the (now?) wrong assumption that default-valued parameters can only be placed after the required ones. Fixes #8683
* WIP: disallow 'nil' for strings and seqsAndreas Rumpf2018-08-131-3/+3
|
* Try conversion to static[T] in generic instantation (#8443)LemonBoy2018-07-301-1/+9
| | | Fixes #8439
* allow referencing other parameters in default parameter valuesZahary Karadjov2018-06-161-1/+3
| | | | | | | | fix #7756 fix #1201 fix #7000 fix #3002 fix #1046
* fixes #7222; fixes #5595; fixes #3747Zahary Karadjov2018-06-161-4/+19
| | | | | | | | | | * late instantiation for the generic procs' default param values * automatic mixin behaviour in concepts Other fixes: * don't render the automatically inserted default params in calls * better rendering of tyFromExpr
* refactoring: remove idents.legacy global variable and pass the IdentCache ↵Andreas Rumpf2018-05-271-5/+5
| | | | around explicitly
* Merge branch 'devel' into araq-big-refactoringAndreas Rumpf2018-05-271-0/+1
|\
| * fix #7883; fix #7829Zahary Karadjov2018-05-261-0/+1
| |
* | remove more global variables in the Nim compilerAndreas Rumpf2018-05-271-2/+2
| |
* | make tests green againAndreas Rumpf2018-05-181-2/+3
|/
* make tests green againAraq2018-05-141-2/+2
|
* more modules compile againAndreas Rumpf2018-05-121-26/+33
|
* sigmatch: speed it upAndreas Rumpf2018-04-281-17/+18
|
* minor speedup: concept tests still greenAndreas Rumpf2018-04-281-3/+4
|
* stuff that is greenAndreas Rumpf2018-04-281-15/+18
|
* .experimental can now be used to enable specific featuresAndreas Rumpf2018-04-241-1/+1
|
* revert the error messageAraq2018-04-061-1/+1
|
* improve compiler error messageAraq2018-04-061-1/+1
|
* fixes #7335Araq2018-03-181-3/+3
|
* make concept tests green againAndreas Rumpf2018-02-271-1/+1
|
* improve the error message for #4659; closes #4659Andreas Rumpf2018-02-251-9/+12
|
* improve the error message for mutability problemsAraq2018-02-171-1/+7
|
* fixes #6186Andreas Rumpf2018-02-111-2/+16
|
* better error messages: use <T1, T2> instead of (T1, T2) in order to prevent ↵Araq2018-02-101-4/+4
| | | | confusions with tuple types
* improve error message for twrongcolonAndreas Rumpf2018-02-061-2/+2
|
* improve the error messages regarding type mismatches in overloading resolutionAndreas Rumpf2018-02-041-2/+16
|
* preparations for language extensions: 'sink' and 'lent' typesAndreas Rumpf2018-01-071-1/+1
|
* make tests green againAraq2017-12-011-2/+0
|
* improve the error messages when overloaded '.' operators are involvedAraq2017-11-301-1/+3
|
* language change: change how the experimental dot operators workAndreas Rumpf2017-11-291-5/+4
|
* made nimresolve part of the compilerAndreas Rumpf2017-10-291-1/+1
|
* deprecated unary '<'Andreas Rumpf2017-10-291-2/+2
|
* preparations for another bugfixAndreas Rumpf2017-10-191-0/+4
|
* first implementation of the 'func' keywordAndreas Rumpf2017-09-231-1/+1
|
* fix #1017; fix #3309Zahary Karadjov2017-06-201-1/+2
|
* improve confusing error messages for failed overloading resolution when ↵Araq2017-05-311-1/+7
| | | | deref of first arg failed
* doh, forgot to add all files in the previous commitZahary Karadjov2017-05-121-1/+1
|
* fixes #5638Araq2017-04-041-3/+1
|
 


                                                                           









                                   
                                                            
                                                                                                
                                                                                                                                               










                                                                                                
                                                        
 
 

























                                                                                          



                                                                            

                                                                                     
       
                                            





                                                                                                               







































                                                                          
//:: Some helpers for debugging.

//: Load the 'map' file generated during 'bootstrap --debug translate' when running
//: 'bootstrap --trace run'.
//: (It'll only affect the trace.)

:(before "End Globals")
map</*address*/uint32_t, string> Symbol_name;  // used only by 'bootstrap run'
map</*address*/uint32_t, string> Source_line;  // used only by 'bootstrap run'
:(before "End --trace Settings")
load_labels();
load_source_lines();
:(code)
void load_labels() {
  ifstream fin("labels");
  if (fin.fail()) return;
  fin >> std::hex;
  while (has_data(fin)) {
    uint32_t addr = 0;
    fin >> addr;
    string name;
    fin >> name;
    put(Symbol_name, addr, name);
  }
}

void load_source_lines() {
  ifstream fin("source_lines");
  if (fin.fail()) return;
  fin >> std::hex;
  while (has_data(fin)) {
    uint32_t addr = 0;
    fin >> addr;
    string line;
    getline(fin, line);
    put(Source_line, addr, hacky_squeeze_out_whitespace(line));
  }
}

:(after "Run One Instruction")
if (contains_key(Symbol_name, EIP))
  trace(Callstack_depth, "run") << "== label " << get(Symbol_name, EIP) << end();
if (contains_key(Source_line, EIP))
  trace(Callstack_depth, "run") << "inst: " << get(Source_line, EIP) << end();
else
  // no source line info; do what you can
  trace(Callstack_depth, "run") << "inst: " << debug_info(EIP) << end();

:(code)
string debug_info(uint32_t inst_address) {
  uint8_t op = read_mem_u8(inst_address);
  if (op != 0xe8) {
    ostringstream out;
    out << HEXBYTE << NUM(op);
    return out.str();
  }
  int32_t offset = read_mem_i32(inst_address+/*skip op*/1);
  uint32_t next_eip = inst_address+/*inst length*/5+offset;
  if (contains_key(Symbol_name, next_eip))
    return "e8/call "+get(Symbol_name, next_eip);
  ostringstream out;
  out << "e8/call 0x" << HEXWORD << next_eip;
  return out.str();
}

//: If a label starts with '$watch-', make a note of the effective address
//: computed by the next instruction. Start dumping out its contents to the
//: trace after every subsequent instruction.

:(after "Run One Instruction")
dump_watch_points();
:(before "End Globals")
map<string, uint32_t> Watch_points;
:(before "End Reset")
Watch_points.clear();
:(code)
void dump_watch_points() {
  if (Watch_points.empty()) return;
  trace(Callstack_depth, "dbg") << "watch points:" << end();
  for (map<string, uint32_t>::iterator p = Watch_points.begin();  p != Watch_points.end();  ++p)
    trace(Callstack_depth, "dbg") << "  " << p->first << ": " << HEXWORD << p->second << " -> " << HEXWORD << read_mem_u32(p->second) << end();
}

:(before "End Globals")
string Watch_this_effective_address;
:(after "Run One Instruction")
Watch_this_effective_address = "";
if (contains_key(Symbol_name, EIP) && starts_with(get(Symbol_name, EIP), "$watch-"))
  Watch_this_effective_address = get(Symbol_name, EIP);
:(after "Found effective_address(addr)")
if (!Watch_this_effective_address.empty()) {
  dbg << "now watching " << HEXWORD << addr << " for " << Watch_this_effective_address << end();
  put(Watch_points, Watch_this_effective_address, addr);
}

//: If a label starts with '$dump-stack', dump out to the trace n bytes on
//: either side of ESP.

:(after "Run One Instruction")
if (contains_key(Symbol_name, EIP) && starts_with(get(Symbol_name, EIP), "$dump-stack")) {
  dump_stack(64);
}
:(code)
void dump_stack(int n) {
  uint32_t stack_pointer = Reg[ESP].u;
  uint32_t start = ((stack_pointer-n)&0xfffffff0);
  dbg << "stack:" << end();
  for (uint32_t addr = start;  addr < start+n*2;  addr+=16) {
    if (addr >= AFTER_STACK) break;
    ostringstream out;
    out << HEXWORD << addr << ":";
    for (int i = 0;  i < 16;  i+=4) {
      out << ' ';
      out << ((addr+i == stack_pointer) ? '[' : ' ');
      out << HEXWORD << read_mem_u32(addr+i);
      out << ((addr+i == stack_pointer) ? ']' : ' ');
    }
    dbg << out.str() << end();
  }
}

//: Special label that dumps regions of memory.
//: Not a general mechanism; by the time you get here you're willing to hack
//: on the emulator.
:(after "Run One Instruction")
if (contains_key(Symbol_name, EIP) && get(Symbol_name, EIP) == "$dump-stream-at-EAX")
  dump_stream_at(Reg[EAX].u);
:(code)
void dump_stream_at(uint32_t stream_start) {
  int32_t stream_length = read_mem_i32(stream_start + 8);
  dbg << "stream length: " << std::dec << stream_length << end();
  for (int i = 0;  i < stream_length + 12;  ++i)
    dbg << "0x" << HEXWORD << (stream_start+i) << ": " << HEXBYTE << NUM(read_mem_u8(stream_start+i)) << end();
}

//: helpers

:(code)
string hacky_squeeze_out_whitespace(const string& s) {
  // strip whitespace at start
  string::const_iterator first = s.begin();
  while (first != s.end() && isspace(*first))
    ++first;
  if (first == s.end()) return "";

  // strip whitespace at end
  string::const_iterator last = --s.end();
  while (last != s.begin() && isspace(*last))
    --last;
  ++last;

  // replace runs of spaces/dots with single space until comment or string
  // TODO:
  //   leave alone dots not surrounded by whitespace
  //   leave alone '#' within word
  //   leave alone '"' within word
  //   squeeze spaces after end of string
  ostringstream out;
  bool previous_was_space = false;
  bool in_comment_or_string = false;
  for (string::const_iterator curr = first;  curr != last;  ++curr) {
    if (in_comment_or_string)
      out << *curr;
    else if (isspace(*curr) || *curr == '.')
      previous_was_space = true;
    else {
      if (previous_was_space)
        out << ' ';
      out << *curr;
      previous_was_space = false;
      if (*curr == '#' || *curr == '"') in_comment_or_string = true;
    }
  }
  return out.str();
}