Esempio n. 1
0
void Cyc_Callgraph_print_callgraph(struct Cyc___cycFILE * f,struct Cyc_Dict_Dict cg) {
  void (* _T0)(struct Cyc___cycFILE *,struct Cyc_Dict_Dict,void (*)(struct Cyc___cycFILE *,
								    struct Cyc_Absyn_Fndecl *));
  void (* _T1)(struct Cyc___cycFILE *,struct Cyc_Dict_Dict,void (*)(struct Cyc___cycFILE *,
								    void *));
  struct Cyc___cycFILE * _T2;
  struct Cyc_Dict_Dict _T3;
  _T1 = Cyc_Graph_print;
  { void (* _T4)(struct Cyc___cycFILE *,struct Cyc_Dict_Dict,void (*)(struct Cyc___cycFILE *,
								      struct Cyc_Absyn_Fndecl *)) = (void (*)(struct Cyc___cycFILE *,
													      struct Cyc_Dict_Dict,
													      void (*)(struct Cyc___cycFILE *,
														       struct Cyc_Absyn_Fndecl *)))_T1;
    _T0 = _T4;
  }_T2 = f;
  _T3 = cg;
  _T0(_T2,_T3,Cyc_Callgraph_print_fndecl);
}
Esempio n. 2
0
struct Cyc_Dict_Dict Cyc_Callgraph_compute_callgraph(struct Cyc_List_List * ds) {
  struct Cyc_Hashtable_Table * (* _T0)(int,int (*)(struct _tuple0 *,struct _tuple0 *),
				       int (*)(struct _tuple0 *));
  struct Cyc_Hashtable_Table * (* _T1)(int,int (*)(void *,void *),int (*)(void *));
  int (* _T2)(struct _tuple0 *,struct _tuple0 *);
  int (* _T3)(struct _tuple0 *);
  struct Cyc_Hashtable_Table * _T4;
  struct Cyc_Dict_Dict (* _T5)(int (*)(struct Cyc_Absyn_Fndecl *,struct Cyc_Absyn_Fndecl *));
  struct Cyc_Dict_Dict (* _T6)(int (*)(void *,void *));
  struct Cyc_Dict_Dict _T7;
  struct Cyc_List_List * _T8;
  struct Cyc_Dict_Dict _T9;
  _T1 = Cyc_Hashtable_create;
  { struct Cyc_Hashtable_Table * (* _TA)(int,int (*)(struct _tuple0 *,struct _tuple0 *),
					 int (*)(struct _tuple0 *)) = (struct Cyc_Hashtable_Table * (*)(int,
													int (*)(struct _tuple0 *,
														struct _tuple0 *),
													int (*)(struct _tuple0 *)))_T1;
    _T0 = _TA;
  }_T2 = Cyc_Absyn_qvar_cmp;
  _T3 = Cyc_Absyn_hash_qvar;
  { struct Cyc_Hashtable_Table * fd = _T0(51,_T2,_T3);
    _T4 = fd;
    _T6 = Cyc_Graph_empty;
    { struct Cyc_Dict_Dict (* _TA)(int (*)(struct Cyc_Absyn_Fndecl *,struct Cyc_Absyn_Fndecl *)) = (struct Cyc_Dict_Dict (*)(int (*)(struct Cyc_Absyn_Fndecl *,
																     struct Cyc_Absyn_Fndecl *)))_T6;
      _T5 = _TA;
    }_T7 = _T5(Cyc_Callgraph_fndecl_cmp);
    _T8 = ds;
    { struct Cyc_Dict_Dict cg = Cyc_Callgraph_enter_fndecls(_T4,_T7,_T8);
      cg = Cyc_Callgraph_cg_topdecls(fd,cg,ds);
      _T9 = cg;
      return _T9;
    }
  }
}
Esempio n. 3
0
static void Cyc_RenameTemps_rename_stmt(struct Cyc_RenameTemps_Env*env,struct Cyc_Absyn_Stmt*s){void(*_T0)(int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Exp*),int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*),struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*);void(*_T1)(int(*)(void*,struct Cyc_Absyn_Exp*),int(*)(void*,struct Cyc_Absyn_Stmt*),void*,struct Cyc_Absyn_Stmt*);struct Cyc_RenameTemps_Env*_T2;struct Cyc_Absyn_Stmt*_T3;_T1=Cyc_Absyn_visit_stmt;{
void(*_T4)(int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Exp*),int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*),struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*)=(void(*)(int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Exp*),int(*)(struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*),struct Cyc_RenameTemps_Env*,struct Cyc_Absyn_Stmt*))_T1;_T0=_T4;}_T2=env;_T3=s;_T0(Cyc_RenameTemps_rename_visit_f1,Cyc_RenameTemps_rename_visit_f2,_T2,_T3);}
Esempio n. 4
0
static struct Cyc_Dict_Dict Cyc_Callgraph_cg_topdecls(struct Cyc_Hashtable_Table * fds,
						      struct Cyc_Dict_Dict cg,
						      struct Cyc_List_List * ds) {
  struct Cyc_Set_Set * (* _T0)(int (*)(struct Cyc_Absyn_Fndecl *,struct Cyc_Absyn_Fndecl *));
  struct Cyc_Set_Set * (* _T1)(int (*)(void *,void *));
  struct Cyc_List_List * _T2;
  void * _T3;
  struct Cyc_Absyn_Decl * _T4;
  int * _T5;
  unsigned int _T6;
  struct Cyc_Dict_Dict (* _T7)(struct Cyc_Dict_Dict,struct Cyc_Absyn_Fndecl *,
			       struct Cyc_Set_Set *);
  struct Cyc_Dict_Dict (* _T8)(struct Cyc_Dict_Dict,void *,struct Cyc_Set_Set *);
  struct Cyc_Dict_Dict _T9;
  struct Cyc_Absyn_Fndecl * _TA;
  struct Cyc_Hashtable_Table * _TB;
  struct Cyc_Absyn_Fndecl * _TC;
  struct Cyc_Absyn_Stmt * _TD;
  struct Cyc_Set_Set * _TE;
  struct Cyc_Set_Set * _TF;
  struct Cyc_List_List * _T10;
  struct Cyc_Dict_Dict _T11;
  _T1 = Cyc_Set_empty;
  { struct Cyc_Set_Set * (* _T12)(int (*)(struct Cyc_Absyn_Fndecl *,struct Cyc_Absyn_Fndecl *)) = (struct Cyc_Set_Set * (*)(int (*)(struct Cyc_Absyn_Fndecl *,
																    struct Cyc_Absyn_Fndecl *)))_T1;
    _T0 = _T12;
  }{ struct Cyc_Set_Set * mt = _T0(Cyc_Callgraph_fndecl_cmp);
    { struct Cyc_List_List * _T12 = ds;
      struct Cyc_List_List * ds = _T12;
      _TLD: if (ds != 0) { goto _TLB;
      }else { goto _TLC;
      }
      _TLB: _T2 = ds;
      _T3 = _T2->hd;
      _T4 = (struct Cyc_Absyn_Decl *)_T3;
      { void * _T13 = _T4->r;
	struct Cyc_List_List * _T14;
	struct Cyc_Absyn_Fndecl * _T15;
	_T5 = (int *)_T13;
	_T6 = *_T5;
	switch (_T6) {
	case 1: 
	  { struct Cyc_Absyn_Fn_d_Absyn_Raw_decl_struct * _T16 = (struct Cyc_Absyn_Fn_d_Absyn_Raw_decl_struct *)_T13;
	    _T15 = _T16->f1;
	  }{ struct Cyc_Absyn_Fndecl * fd = _T15;
	    _T8 = Cyc_Graph_add_edges;
	    { struct Cyc_Dict_Dict (* _T16)(struct Cyc_Dict_Dict,struct Cyc_Absyn_Fndecl *,
					    struct Cyc_Set_Set *) = (struct Cyc_Dict_Dict (*)(struct Cyc_Dict_Dict,
											      struct Cyc_Absyn_Fndecl *,
											      struct Cyc_Set_Set *))_T8;
	      _T7 = _T16;
	    }_T9 = cg;
	    _TA = fd;
	    _TB = fds;
	    _TC = fd;
	    _TD = _TC->body;
	    _TE = mt;
	    _TF = Cyc_Callgraph_cg_stmt(_TB,_TD,_TE);
	    cg = _T7(_T9,_TA,_TF);
	    goto _LL0;
	  }
	case 10: 
	  { struct Cyc_Absyn_Using_d_Absyn_Raw_decl_struct * _T16 = (struct Cyc_Absyn_Using_d_Absyn_Raw_decl_struct *)_T13;
	    _T14 = _T16->f2;
	  }{ struct Cyc_List_List * ds = _T14;
	    _T14 = ds;
	    goto _LL6;
	  }
	case 9: 
	  { struct Cyc_Absyn_Namespace_d_Absyn_Raw_decl_struct * _T16 = (struct Cyc_Absyn_Namespace_d_Absyn_Raw_decl_struct *)_T13;
	    _T14 = _T16->f2;
	  }_LL6: { struct Cyc_List_List * ds = _T14;
	    cg = Cyc_Callgraph_cg_topdecls(fds,cg,ds);
	    goto _LL0;
	  }
	default: 
	  goto _LL0;
	}
	_LL0: ;
      }_T10 = ds;
      ds = _T10->tl;
      goto _TLD;
      _TLC: ;
    }_T11 = cg;
    return _T11;
  }
}
Esempio n. 5
0
void Cyc_Lineno_poss_of_abss(struct _fat_ptr filename,struct Cyc_List_List * places) {
  struct Cyc_List_List * (* _T0)(int (*)(struct _tuple1 *,struct _tuple1 *),
				 struct Cyc_List_List *);
  struct Cyc_List_List * (* _T1)(int (*)(void *,void *),struct Cyc_List_List *);
  struct Cyc_List_List * _T2;
  struct _fat_ptr _T3;
  struct _fat_ptr _T4;
  struct _handler_cons * _T5;
  int _T6;
  enum Cyc_Lineno_token_val _T7;
  int _T8;
  int _T9;
  struct Cyc_List_List * _TA;
  void * _TB;
  struct _tuple1 * _TC;
  struct _tuple1 _TD;
  int _TE;
  enum Cyc_Lineno_token_val _TF;
  int _T10;
  struct _tuple0 * _T11;
  struct _tuple0 _T12;
  struct _tuple0 * _T13;
  struct _tuple0 _T14;
  enum Cyc_Lineno_token_val _T15;
  int _T16;
  int _T17;
  struct Cyc_List_List * _T18;
  void * _T19;
  struct _tuple1 * _T1A;
  struct _tuple1 _T1B;
  int _T1C;
  struct Cyc_List_List * _T1D;
  void * _T1E;
  struct _tuple1 * _T1F;
  struct _tuple1 _T20;
  struct Cyc_Lineno_Pos * _T21;
  struct Cyc_Lineno_Pos * _T22;
  struct Cyc_Lineno_Pos * _T23;
  struct Cyc_Lineno_Pos * _T24;
  unsigned long _T25;
  int _T26;
  struct Cyc_List_List * _T27;
  void * _T28;
  struct _tuple1 * _T29;
  struct _tuple1 _T2A;
  int _T2B;
  int _T2C;
  unsigned long _T2D;
  unsigned long _T2E;
  struct Cyc_Lineno_Pos * _T2F;
  int _T30;
  struct Cyc_Lineno_Pos * _T31;
  struct Cyc_List_List * _T32;
  void * _T33;
  _T1 = Cyc_List_merge_sort;
  { struct Cyc_List_List * (* _T34)(int (*)(struct _tuple1 *,struct _tuple1 *),
				    struct Cyc_List_List *) = (struct Cyc_List_List * (*)(int (*)(struct _tuple1 *,
												  struct _tuple1 *),
											  struct Cyc_List_List *))_T1;
    _T0 = _T34;
  }_T2 = places;
  places = _T0(Cyc_Lineno_place_cmp,_T2);
  _T3 = filename;
  _T4 = _tag_fat("r",sizeof(char),2U);
  { struct Cyc___cycFILE * f = Cyc_file_open(_T3,_T4);
    { struct _handler_cons _T34;
      _T5 = &_T34;
      _push_handler(_T5);
      { int _T35 = 0;
	_T6 = setjmp(_T34.handler);
	if (! _T6) { goto _TL3A;
	}
	_T35 = 1;
	goto _TL3B;
	_TL3A: _TL3B: if (_T35) { goto _TL3C;
	}else { goto _TL3E;
	}
	_TL3E: { struct Cyc_Lexing_lexbuf * lbuf = Cyc_Lexing_from_file(f);
	  struct _fat_ptr source_file = filename;
	  int line = 1;
	  struct _fat_ptr this_line;
	  int eol;
	  enum Cyc_Lineno_token_val next;
	  _TL3F: if (places != 0) { goto _TL40;
	  }else { goto _TL41;
	  }
	  _TL40: _TL42: if (1) { goto _TL43;
	  }else { goto _TL44;
	  }
	  _TL43: next = Cyc_Lineno_token(lbuf);
	  eol = Cyc_Lexing_lexeme_end(lbuf);
	  this_line = Cyc_Lexing_lexeme(lbuf);
	  _T7 = next;
	  _T8 = (int)_T7;
	  if (_T8 == 2) { goto _TL47;
	  }else { goto _TL48;
	  }
	  _TL48: _T9 = eol;
	  _TA = places;
	  _TB = _TA->hd;
	  _TC = (struct _tuple1 *)_TB;
	  _TD = *_TC;
	  _TE = _TD.f0;
	  if (_T9 > _TE) { goto _TL47;
	  }else { goto _TL45;
	  }
	  _TL47: goto _TL44;
	  _TL45: _TF = next;
	  _T10 = (int)_TF;
	  if (_T10 != 0) { goto _TL49;
	  }
	  line = line + 1;
	  goto _TL4A;
	  _TL49: { struct _tuple0 * fno = Cyc_Lineno_parse_linedef(this_line);
	    if (fno != 0) { goto _TL4B;
	    }
	    line = line + 1;
	    goto _TL4C;
	    _TL4B: _T11 = fno;
	    _T12 = *_T11;
	    source_file = _T12.f0;
	    _T13 = fno;
	    _T14 = *_T13;
	    line = _T14.f1;
	    _TL4C: ;
	  }_TL4A: goto _TL42;
	  _TL44: _TL4D: if (places != 0) { goto _TL50;
	  }else { goto _TL4F;
	  }
	  _TL50: _T15 = next;
	  _T16 = (int)_T15;
	  if (_T16 == 2) { goto _TL4E;
	  }else { goto _TL51;
	  }
	  _TL51: _T17 = eol;
	  _T18 = places;
	  _T19 = _T18->hd;
	  _T1A = (struct _tuple1 *)_T19;
	  _T1B = *_T1A;
	  _T1C = _T1B.f0;
	  if (_T17 > _T1C) { goto _TL4E;
	  }else { goto _TL4F;
	  }
	  _TL4E: _T1D = places;
	  _T1E = _T1D->hd;
	  _T1F = (struct _tuple1 *)_T1E;
	  _T20 = *_T1F;
	  { struct Cyc_Lineno_Pos * p = _T20.f1;
	    _T21 = p;
	    _T21->logical_file = Cyc_strdup(source_file);
	    _T22 = p;
	    _T22->line = this_line;
	    _T23 = p;
	    _T23->line_no = line;
	    _T24 = p;
	    _T25 = Cyc_strlen(this_line);
	    _T26 = eol;
	    _T27 = places;
	    _T28 = _T27->hd;
	    _T29 = (struct _tuple1 *)_T28;
	    _T2A = *_T29;
	    _T2B = _T2A.f0;
	    _T2C = _T26 - _T2B;
	    _T2D = (unsigned long)_T2C;
	    _T2E = _T25 - _T2D;
	    _T24->col = (int)_T2E;
	    _T2F = p;
	    _T30 = _T2F->col;
	    if (_T30 >= 0) { goto _TL52;
	    }
	    _T31 = p;
	    _T31->col = 0;
	    goto _TL53;
	    _TL52: _TL53: _T32 = places;
	    places = _T32->tl;
	  }goto _TL4D;
	  _TL4F: line = line + 1;
	  goto _TL3F;
	  _TL41: ;
	}_pop_handler();
	goto _TL3D;
	_TL3C: _T33 = Cyc_Core_get_exn_thrown();
	{ void * _T36 = (void *)_T33;
	  void * _T37;
	  _T37 = _T36;
	  { void * y = _T37;
	    Cyc_file_close(f);
	    _throw(y);
	  };
	}_TL3D: ;
      }
    }Cyc_file_close(f);
    return;
  }
}
Esempio n. 6
0
static int Cyc_Compact_most_frequent_elt(struct _fat_ptr v) {
  struct Cyc_Hashtable_Table * (* _T0)(int,int (*)(int,int),int (*)(int));
  struct Cyc_Hashtable_Table * (* _T1)(int,int (*)(void *,void *),int (*)(void *));
  int (* _T2)(int,int);
  int (* _T3)(int);
  void * (* _T4)(void *);
  int _T5;
  unsigned int _T6;
  struct _fat_ptr _T7;
  unsigned int _T8;
  struct _fat_ptr _T9;
  unsigned char * _TA;
  int * _TB;
  int * _TC;
  int _TD;
  struct _handler_cons * _TE;
  int _TF;
  int * (* _T10)(struct Cyc_Hashtable_Table *,int);
  void * (* _T11)(struct Cyc_Hashtable_Table *,void *);
  void * _T12;
  struct Cyc_Core_Not_found_exn_struct * _T13;
  char * _T14;
  char * _T15;
  int * _T16;
  struct _RegionHandle * _T17;
  void (* _T18)(struct Cyc_Hashtable_Table *,int,int *);
  void (* _T19)(struct Cyc_Hashtable_Table *,void *,void *);
  int * _T1A;
  int _T1B;
  int * _T1C;
  struct _RegionHandle _T1D = _new_region(0U,"rgn");
  struct _RegionHandle * rgn = &_T1D;
  _push_region(rgn);
  _T1 = Cyc_Hashtable_create;
  { struct Cyc_Hashtable_Table * (* _T1E)(int,int (*)(int,int),int (*)(int)) = (struct Cyc_Hashtable_Table * (*)(int,
														 int (*)(int,
															 int),
														 int (*)(int)))_T1;
    _T0 = _T1E;
  }_T2 = Cyc_Core_intcmp;
  _T4 = Cyc_Core_identity;
  { int (* _T1E)(int) = (int (*)(int))_T4;
    _T3 = _T1E;
  }{ struct Cyc_Hashtable_Table * frequencies = _T0(17,_T2,_T3);
    int max_freq = 0;
    int most_freq = 0;
    { int i = 0;
      _TL3: _T5 = i;
      _T6 = (unsigned int)_T5;
      _T7 = v;
      _T8 = _get_fat_size(_T7,sizeof(int));
      if (_T6 < _T8) { goto _TL1;
      }else { goto _TL2;
      }
      _TL1: _T9 = v;
      _TA = _T9.curr;
      _TB = (int *)_TA;
      _TC = _check_null(_TB);
      _TD = i;
      { int e = _TC[_TD];
	int * r;
	{ struct _handler_cons _T1E;
	  _TE = &_T1E;
	  _push_handler(_TE);
	  { int _T1F = 0;
	    _TF = setjmp(_T1E.handler);
	    if (! _TF) { goto _TL4;
	    }
	    _T1F = 1;
	    goto _TL5;
	    _TL4: _TL5: if (_T1F) { goto _TL6;
	    }else { goto _TL8;
	    }
	    _TL8: _T11 = Cyc_Hashtable_lookup;
	    { int * (* _T20)(struct Cyc_Hashtable_Table *,int) = (int * (*)(struct Cyc_Hashtable_Table *,
									    int))_T11;
	      _T10 = _T20;
	    }r = _T10(frequencies,e);
	    _pop_handler();
	    goto _TL7;
	    _TL6: _T12 = Cyc_Core_get_exn_thrown();
	    { void * _T20 = (void *)_T12;
	      void * _T21;
	      _T13 = (struct Cyc_Core_Not_found_exn_struct *)_T20;
	      _T14 = _T13->tag;
	      _T15 = Cyc_Core_Not_found;
	      if (_T14 != _T15) { goto _TL9;
	      }
	      _T17 = rgn;
	      { int * _T22 = _region_malloc(_T17,0U,sizeof(int));
		*_T22 = 0;
		_T16 = (int *)_T22;
	      }r = _T16;
	      _T19 = Cyc_Hashtable_insert;
	      { void (* _T22)(struct Cyc_Hashtable_Table *,int,int *) = (void (*)(struct Cyc_Hashtable_Table *,
										  int,
										  int *))_T19;
		_T18 = _T22;
	      }_T18(frequencies,e,r);
	      goto _LL0;
	      _TL9: _T21 = _T20;
	      { void * exn = _T21;
		_rethrow(exn);
	      }_LL0: ;
	    }_TL7: ;
	  }
	}_T1A = r;
	_T1B = *_T1A;
	{ int f = _T1B + 1;
	  _T1C = r;
	  *_T1C = f;
	  if (f <= max_freq) { goto _TLB;
	  }
	  max_freq = f;
	  most_freq = e;
	  goto _TLC;
	  _TLB: _TLC: ;
	}
      }i = i + 1;
      goto _TL3;
      _TL2: ;
    }{ int _T1E = most_freq;
      _npop_handler(0);
      return _T1E;
    }
  }_pop_region();
}