Example #1
0
static bool dump_upvalue(struct luadebug_debugger *session, const char *option)
{
	int i;
	const char *local;
	const int index = option ? atoi(option) : -1;

	lua_getinfo(session->L, "f", &session->frame);

	if (index < 0) {
		session->user->print(session->user, "Up-values\n");
		for (i=1; (local = lua_getupvalue(session->L, -1, i)); ++i) {
			session->user->print(session->user, "  #%d\t%s = ", i, local);
			pprint(session->L, session->user, -1, false, NULL);
			lua_pop(session->L, 1);
		}
	}
	else {
		local = lua_getupvalue(session->L, -1, index);
		if (!local) {
			session->user->print(session->user, RED "invalid up-value index '%d'\n" CLEAR, index);
		}
		else {
			session->user->print(session->user, "  #%d\t%s = ", index, local);
			pprint(session->L, session->user, -1, true, NULL);
			lua_pop(session->L, 1);
		}
	}

	lua_pop(session->L, 1);
	return false;
}
Example #2
0
/* Affichage prefixe d'une expression binaire */
void pprintPrefixTree2(TreeP tree, char *op) {
  printf("(%s", op);
  pprint(getChild(tree, 0));
  printf(" ");
  pprint(getChild(tree, 1));
  printf(")");
}
Example #3
0
/* Affichage d'un while do */
void pprintWhile(TreeP tree) {
  printf("(While ");
  pprint(getChild(tree, 0));
  printf(" do ");
  pprint(getChild(tree, 1));
  printf(")");
}
Example #4
0
/* Affichage d'une expression binaire */
void pprintTree2(TreeP tree, char *op) {
  printf("(");
  pprint(getChild(tree, 0));
  printf("%s", op);
  pprint(getChild(tree, 1));
  printf(")");
}
Example #5
0
void pprintList(TreeP tree){
  if(getChild(tree,1) != NULL){
    pprint(getChild(tree, 1));
    printf(",");
  }
  pprint(getChild(tree, 0));
}
Example #6
0
/* Affichage d'un if then else */
void pprintIf(TreeP tree) {
	
	/* instruction if */
	printIndentation();
	printf("SI ");
	pprint(getChild(tree, 0));
	printf(" ALORS\n");

	/*debut du bloc d'instructions*/
	indent++;
	pprint(getChild(tree, 1));
	indent--;
	
	/* y a-t-il un bloc 'else' ? */
	if(tree->nbChildren==3){
		printf("\n");
		printIndentation();
		printf("SINON\n");
		/* debut du bloc else */
		indent++;
		pprint(getChild(tree, 2));
		indent--;
	}
	
	/* fin du dernier bloc defini */
	printf("\n");
	printIndentation();
	printf("FINDESI");

}
Example #7
0
void
cprint(Chan *c, Mntcache *m, char *s)
{
	ulong o;
	int nb, ct;
	Extent *e;

	nb = 0;
	ct = 1;
	o = 0;
	if(m->list)
		o = m->list->start;
	for(e = m->list; e; e = e->next) {
		nb += e->len;
		if(o != e->start)
			ct = 0;
		o = e->start+e->len;
	}
	pprint("%s: %#llux.%#lux %d %d %s (%d %c)\n",
	s, m->qid.path, m->qid.vers, m->type, m->dev, c->path->s, nb, ct ? 'C' : 'N');

	for(e = m->list; e; e = e->next) {
		pprint("\t%4d %5lud %4d %#p\n",
			e->bid, e->start, e->len, e->cache);
	}
}
Example #8
0
void pprintNew(TreeP tree){
  printf("new ");
  pprint(getChild(tree, 0));
  printf("(");
  pprint(getChild(tree, 1));
  printf(")");
}
Example #9
0
static void do_disassemble(const char *triple, const char *features,
                           unsigned char *buf, int siz) {
  LLVMDisasmContextRef D = LLVMCreateDisasmCPUFeatures(triple, "", features,
                                                       NULL, 0, NULL, NULL);
  char outline[1024];
  int pos;

  if (!D) {
    printf("ERROR: Couldn't create disassembler for triple %s\n", triple);
    return;
  }

  pos = 0;
  while (pos < siz) {
    size_t l = LLVMDisasmInstruction(D, buf + pos, siz - pos, 0, outline,
                                     sizeof(outline));
    if (!l) {
      pprint(pos, buf + pos, 1, "\t???");
      pos++;
    } else {
      pprint(pos, buf + pos, l, outline);
      pos += l;
    }
  }

  LLVMDisasmDispose(D);
}
Example #10
0
        static short pprpa(
        pm_ptr pala)

/*      Print module parameter.
 *
 *      In:    nplist  =>  PM-pointer to module parameter node 
 *
 *      FV:    return  -   error severity code
 *
 *      (C)microform ab 1986-03-21 Per-Ove Agne'
 *
 *      1999-11-19 Rewritten, R. Svedin
 *
 ******************************************************!*/

  {
   PMPANO *np;             /* c-pointer to module parameter node */
   string str;
   char tmpstr[ PPLINLEN ];
   STVAR var;              /* interface struct for a parameter */
   short status;

   if ( ( status = pmgpar( pala, &np ) ) )
      {  
      return( status );    /* Error */
      }

   if ( np->noclpa != PARAM )
      {  
      return( erpush( "PM2532", "" ) );   /*Error  Not an module parameter node */
      }

   ppdecl( np->fopa_ );                   /* print formal parameter name */ 

/*
***get and print default value
*/
   if ( ( status = strvar( np->fopa_, &var ) ) != 0 )
      return( status );

   if ( var.def_va != (pm_ptr)NULL )
      {
      pprint( ":=" );
      pprex( var.def_va, PP_NOPRI );
      }

   if ( ( status = pmgstr( np->ppro_, &str ) ) != 0 )
      return( status );

   if ( strlen( str ) > 0 )
      {
      pprint( " > " );
      strcpy( tmpstr, str );
      fixsli( tmpstr );
      pprint( tmpstr );
      }

  return( 0 );
  }
Example #11
0
void pprintYield(TreeP tree){
  printf("yield ");
  pprint(getChild(tree, 0));
  if(tree->nbChildren == 2){
    printf(":");
    pprint(getChild(tree, 1));
  }
}
Example #12
0
File: shell.c Project: a4a881d4/nvc
static void event_watch(event_watch_msg_t *event, tree_rd_ctx_t ctx)
{
   tree_t decl = tree_read_recall(ctx, event->index);

   printf("%s: update %s ", event->now_text, istr(tree_ident(decl)));
   printf("%s -> ", pprint(decl, &(event->last), 1));
   printf("%s\n", pprint(decl, &(event->value), 1));
}
Example #13
0
void pprintDec(TreeP tree){
  printf("var ");
  pprint(getChild(tree, 0));
  printf(" : ");
  pprint(getChild(tree, 1));
  pprint(getChild(tree, 2));
  printf(";\n");
  pprint(getChild(tree,3)); 
}
Example #14
0
void pprint(BTNode* t){  
        printf("(");  
        if(t!=NULL){   
                printf("%c",t->data);  
                pprint(t->lchild);  
                pprint(t->rchild);  
        }  
        printf(")");  
}  
Example #15
0
static void psymbol(node s){
     assertpos(s->tag == symbol_tag,s);
     cprint(s->body.symbol.name);
     if (s->body.symbol.cprintvalue) {
	  put("\n      cprintvalue => ");
	  cprint(s->body.symbol.cprintvalue);
	  put("\n      ");
	  }
     if (s->body.symbol.Cname != NULL) {
	  put("\n      Cname => ");
	  put(s->body.symbol.Cname);
	  }
     put("\n      type => ");
     pprint(s->body.symbol.type);
     put("\n      value => ");
     if (s->body.symbol.value != NULL) {
	  node val = s->body.symbol.value;
	  if (istype(val) && val->body.type.name == s) {
	       pprint(val->body.type.definition);
	       }
	  else pprint(val);
	  }
     else {
       put("none");
       }
     put("\n      flags:");
     if (s->body.symbol.flags & macro_function_F) put(" macro-function");
     if (s->body.symbol.flags & macro_variable_F) put(" macro-variable");
     if (s->body.symbol.flags & readonly_F) put(" readonly");
     if (s->body.symbol.flags & symbol_F) put(" symbol");
     if (s->body.symbol.flags & keyword_F) put(" keyword");
     if (s->body.symbol.flags & constant_F) put(" constant");
     if (s->body.symbol.flags & defined_F) put(" initialized");
     if (s->body.symbol.flags & export_F) put(" export");
     if (s->body.symbol.flags & import_F) put(" import");
     if (s->body.symbol.flags & threadLocal_F) put(" thread");
     if (s->body.symbol.flags & const_F) put(" const");
     if (s->body.symbol.flags & global_F) put(" global");
     if (s->body.symbol.flags & literal_F) put(" literal");
     if (s->body.symbol.flags & visible_F) put(" visible");
     if ( !(s->body.symbol.flags & defined_F) && !(s->body.symbol.flags & import_F) ) put(" (never initialized)");
     if (s->body.symbol.args != NULL) {
	  put("\n      args => ");
	  cprintlist(s->body.symbol.args);
	  }
     if (s->body.symbol.body != NULL) {
	  put("\n      body => ");
	  pprint(s->body.symbol.body);
	  }
     if (s->body.symbol.export_list != NULL) {
	  put("\n      export_list => ");
	  cprintlist(s->body.symbol.export_list);
	  }
     pput("\n");
     }
Example #16
0
/* Affichage d'un if then else */
void pprintIf(TreeP tree) {
  printf("(if ");
  pprint(getChild(tree, 0));
  printf(" then ");
  pprint(getChild(tree, 1));
  if(tree->nbChildren == 3){
    printf(" else ");
    pprint(getChild(tree, 2));
  }
  printf(")");
}
Example #17
0
/* Affichage d'un bloc */
void pprintBloc(TreeP tree) {
  printf(" { ");
  if (tree->nbChildren == 2){
    pprint(getChild(tree, 0));
    printf(" | ");
    pprint(getChild(tree, 1));
  }else {
    pprint(getChild(tree, 0));
  }
  printf(" } ");
}
Example #18
0
void pprintAffectation(TreeP tree){
	int old_indent = indent;
	printIndentation();
	pprint(getChild(tree,0));
	printf(" := ");
	indent = 0;
	pprint(getChild(tree,1));
	indent = old_indent;
	if(getChild(tree, 1)->op != AFF)
		printf(";");
}
Example #19
0
/* Affichage de la boucle faire - tantque */
void pprintFaireTantQue(TreeP tree) {
  printIndentation();
  printf("FAIRE\n");
  indent++;
  pprint(getChild(tree,0));
  indent--;
  printf("\n");
  printIndentation();
  printf("TANTQUE ");
  pprint(getChild(tree,1));
  printf("FINTANTQUE");
}
Example #20
0
File: shell.c Project: SnookEE/nvc
static void event_watch(uint64_t now, tree_t decl, watch_t *w, void *user)
{
   uint64_t value[1];
   rt_watch_value(w, value, 1, false);

   uint64_t last[1];
   rt_watch_value(w, last, 1, true);

   LOCAL_TEXT_BUF last_tb = pprint(decl, last, 1);
   LOCAL_TEXT_BUF now_tb  = pprint(decl, value, 1);
   printf("%s: update %s %s -> %s\n", fmt_time(rt_now(NULL)),
          istr(tree_ident(decl)), tb_get(last_tb), tb_get(now_tb));
}
Example #21
0
void pprintMes(TreeP tree){
  if(tree->nbChildren == 3){
    pprintTree2(tree, ".");
    printf("(");
    pprint(getChild(tree, 2));
    printf(")");
  }else{
    pprint(getChild(tree, 0));
    printf("(");
    pprint(getChild(tree, 1));
    printf(");");
  }
}
Example #22
0
void printstringlist(){
     node p;
     unsigned int h;
     pput("String Table\n");
     for (h=0; h<numberof(hash_buckets); h++) {
	  for (p = hash_buckets[h]; p != NULL; p = CDR(p)) {
	       node str = CAR(p);
	       assertpos(isstr(str),str);
	       pprint(str);
	       pput(" : ");
	       pprint(str->body.unique_string.symbol_list);
	       pput("\n");
	       }
	  }
     pput("\n");
     }
Example #23
0
int main(){
        srand(time(NULL));
        int i ;BTNode* root=NULL;
        for(i=0;i<N;i++) root =insert_node(root,rand()%50+65);
	pprint(root);
	return 0;
}
Example #24
0
int main(void)
{
  unsigned size = 0;
  size_t cgc_read = 0;
  uint8_t buf[MAX_SIZE];
  cgc_memset(buf, 0, sizeof(buf));

  if (receive(STDIN, &size, sizeof(size), &cgc_read) != 0)
    cgc_exit(1);

  if (cgc_read != 4)
    cgc_exit(1);

  if (size > MAX_SIZE) {
    printf("too big\n");
    cgc_exit(1);
  }

  if (read_exactly(STDIN, buf, size) != 0)
    cgc_exit(1);

  element *e = decode(buf, (unsigned) buf + size);
  if (e == NULL)
    cgc_exit(1);

  pprint(e);
}
Example #25
0
/* Affichage d'un extends */
void pprintExtends (ExtP e){
  if (e!=NULL){
    printf("extends %s(",e->classe->name);
    pprint(e->arg);
    printf(")");
  }
}
Example #26
0
        static int indent(
        short indlev)

/*      Print indentation.
 *
 *      In:    indlev  =>  Indentation level 
 *
 *      FV:    return  -   error severity code
 *
 *      (C)microform ab 1986-03-21 Per-Ove Agne'
 *
 *      1999-11-19 Rewritten, R. Svedin
 *
 ******************************************************!*/

  {
   int i;
   int nustep;

   nustep = indlev * ppindl;
   if ( nustep > MAXIND )
      nustep = MAXIND;

   for ( i = 1; i <= nustep; i++ ) 
      pprint( " " );

   return(0);
  }
Example #27
0
        static short pprpl(
        pm_ptr palist)

/*      Print module parameter list.
 *
 *      In:    palist  =>  PM-pointer to module parameter list 
 *
 *      FV:    return  -   error severity code
 *
 *      (C)microform ab 1986-03-21 Per-Ove Agne'
 *
 *      1999-11-19 Rewritten, R. Svedin
 *
 ******************************************************!*/

  {
   pm_ptr listla;     /* PM-pointer to list node */ 
   pm_ptr nextla;     /* PM-pointer to next list node */
   pm_ptr parala;     /* PM-pointer to module parameter node */
   short status;

   if ( palist == (pm_ptr)NULL )
      {
      return( 0 );
      }
/*
***get first list node in list
*/
   if ( ( status = pmgfli( palist, &listla ) ) != 0 )
      {  
      return( status );                      /* Error */
      }

   if ( listla != (pm_ptr)NULL ) pprlin();   /* Ny rad före 1:a parametern. */

   while ( listla != (pm_ptr)NULL )
      { 
/*
***get contents of list node
*/
      if ( ( status = pmglin( listla, &nextla, &parala ) ) != 0 )
         return( status );

/*
***print parameter
*/
      if ( ( status = pprpa( parala ) ) != 0 )
         return( status );

      listla = nextla;

      if ( listla != (pm_ptr)NULL )
         {
         pprint( ";" );
         pprlin();
         }
      }

   return( 0 );
  }
Example #28
0
tlHandle _to_repr(tlTask* task, tlArgs* args) {
    tlHandle h = tlArgsGet(args, 0);
    if (!h) h = tlNull;

    tlBuffer* buf = tlBufferNew();
    pprint(buf, h, false, false, 0);
    return buf;
}
Example #29
0
tlHandle _repr(tlTask* task, tlArgs* args) {
    tlHandle h = tlArgsGet(args, 0);
    if (!h) h = tlNull;
    tlBuffer* buf = tlBufferNew();
    pprint(buf, h, false, true, 0);
    tlBufferWrite(buf, "\0", 1);
    return tlStringFromTake(tlBufferTakeData(buf), tlBufferSize(buf) - 1);
}
Example #30
0
/* Impression de la declaration en tete de l'arbre. On suppose que
 * les autres auront deja ete traitees auparavant
 */
void pprintDecl(TreeP tree) {
  if (! verbose) return;
  if (tree->op != AFF) { abort(); }
  printf("%s := ", getChild(tree, 0)->u.str);  /*le nom de la variable */
  pprint(getChild(tree, 1));		/* le texte de l'expression */
   /* utile au cas ou l'evaluation se passerait mal ! */
  fflush(NULL);
}