src/interp/alloc.c
/*====================================================
 * debug_show_one_pnode -- DEBUG routine to describe one node
 *  appending description into zstring
 *  but not more than max chars
 *==================================================*/
- DEBUG routine to describe one node
appending description into zstring
but not more than max chars
- DEBUG routine to describe one node appending description into zstring but not more than max chars
void
describe_pnode (PNODE node, ZSTR zstr, INT max)
{
	if ((INT)zs_len(zstr) >= max-2)
		return;
	if ((INT)zs_len(zstr) >= max-7) {
		if (zs_str(zstr)[zs_len(zstr)-1] != '.')
			zs_apps(zstr, "...");
		return;
	}
	switch (itype(node)) {
	case IICONS:
		zs_appf(zstr, FMT_INT, pvalue_to_int(node->vars.iicons.value));
		break;
	case IFCONS:
		zs_appf(zstr, "%f", pvalue_to_float(node->vars.ifcons.value));
		break;
	case ISCONS:
		zs_appf(zstr, "^^%s^^", pvalue_to_string(node->vars.iscons.value));
		break;
	case IIDENT:
		zs_appf(zstr, "%s", iident_name(node));
		break;
	case IIF:
		zs_apps(zstr, "if(");
		describe_pnodes(node->vars.iif.icond, zstr, max);
		zs_apps(zstr, "){");
		describe_pnodes(node->vars.iif.ithen, zstr, max);
		zs_apps(zstr, "}");
		if (node->vars.iif.ielse) {
			zs_apps(zstr, "else{");
			describe_pnodes(node->vars.iif.ielse, zstr, max);
			zs_apps(zstr, "}");
		}
		break;
	case IWHILE:
		zs_apps(zstr, "while(");
		describe_pnodes(node->vars.iwhile.icond, zstr, max);
		zs_apps(zstr, "){");
		describe_pnodes(node->vars.iwhile.ibody, zstr, max);
		zs_apps(zstr, "}");
		break;
	case IBREAK:
		zs_apps(zstr, "break ");
		break;
	case ICONTINUE:
		zs_apps(zstr, "continue ");
		break;
	case IRETURN:
		zs_apps(zstr, "return(");
		describe_pnodes(iargs(node), zstr, max);
		zs_apps(zstr, ")");
		break;
	case IPDEFN:
		zs_apps(zstr, "*PDefn *");
		break;
	case IPCALL:
		zs_appf(zstr, "%s(", (char*)iname(node));
		describe_pnodes(iargs(node), zstr, max);
		zs_apps(zstr, ")");
		break;
	case IFDEFN:
		zs_apps(zstr, "*FDefn *");
		break;
	case IFCALL:
		zs_appf(zstr, "%s(", (char*)iname(node));
		describe_pnodes(iargs(node), zstr, max);
		zs_apps(zstr, ")");
		break;
	case IBCALL:
		zs_appf(zstr, "%s(", (char*)iname(node));
		describe_pnodes(iargs(node), zstr, max);
		zs_apps(zstr, ")");
		break;
	case ITRAV:
		zs_apps(zstr, "*Traverse *");
		break;
	case INODES:
		zs_apps(zstr, "*Fornodes *");
		break;
	case IFAMILIES:
		zs_apps(zstr, "*FamiliesLoop *");
		break;
	case ISPOUSES:
		zs_apps(zstr, "*SpousesLoop *");
		break;
	case ICHILDREN:
		zs_apps(zstr, "*ChildrenLoop *");
		break;
	case IFAMILYSPOUSES:
		zs_apps(zstr, "*FamilySpousesLoop *");
		break;
	case IINDI:
		zs_apps(zstr, "*PersonLoop *");
		break;
	case IFAM:
		zs_apps(zstr, "*FamilyLoop *");
		break;
	case ISOUR:
		zs_apps(zstr, "*SourceLoop *");
		break;
	case IEVEN:
		zs_apps(zstr, "*EventLoop *");
		break;
	case IOTHR:
		zs_apps(zstr, "*OtherLoop *");
		break;
	case ILIST:
		zs_apps(zstr, "*ListLoop *");
		break;
	case ISET:
		zs_apps(zstr, "*IndisetLoop *");
		break;
	case IFATHS:
		zs_apps(zstr, "*FathersLoop *");
		break;
	case IMOTHS:
		zs_apps(zstr, "*MothersLoop *");
		break;
	case IFAMCS:
		zs_apps(zstr, "*ParentsLoop *");
		break;
	case INOTES:
		zs_apps(zstr, "*NotesLoop *");
		break;
	default:
		break;
	}
}
void describe_pnode ( PNODE node , ZSTR zstr , INT max ) { if ( ( INT ) zs_len ( zstr ) >= max - 2 ) return ; if ( ( INT ) zs_len ( zstr ) >= max - 7 ) { if ( zs_str ( zstr ) [ zs_len ( zstr ) - 1 ] != ' ' ) zs_apps ( zstr , " " ) ; return ; } switch ( itype ( node ) ) { case IICONS : zs_appf ( zstr , FMT_INT , pvalue_to_int ( node -> vars . iicons . value ) ) ; break ; case IFCONS : zs_appf ( zstr , " " , pvalue_to_float ( node -> vars . ifcons . value ) ) ; break ; case ISCONS : zs_appf ( zstr , " " , pvalue_to_string ( node -> vars . iscons . value ) ) ; break ; case IIDENT : zs_appf ( zstr , " " , iident_name ( node ) ) ; break ; case IIF : zs_apps ( zstr , " " ) ; describe_pnodes ( node -> vars . iif . icond , zstr , max ) ; zs_apps ( zstr , " " ) ; describe_pnodes ( node -> vars . iif . ithen , zstr , max ) ; zs_apps ( zstr , " " ) ; if ( node -> vars . iif . ielse ) { zs_apps ( zstr , " " ) ; describe_pnodes ( node -> vars . iif . ielse , zstr , max ) ; zs_apps ( zstr , " " ) ; } break ; case IWHILE : zs_apps ( zstr , " " ) ; describe_pnodes ( node -> vars . iwhile . icond , zstr , max ) ; zs_apps ( zstr , " " ) ; describe_pnodes ( node -> vars . iwhile . ibody , zstr , max ) ; zs_apps ( zstr , " " ) ; break ; case IBREAK : zs_apps ( zstr , " " ) ; break ; case ICONTINUE : zs_apps ( zstr , " " ) ; break ; case IRETURN : zs_apps ( zstr , " " ) ; describe_pnodes ( iargs ( node ) , zstr , max ) ; zs_apps ( zstr , " " ) ; break ; case IPDEFN : zs_apps ( zstr , " " ) ; break ; case IPCALL : zs_appf ( zstr , " " , ( char * ) iname ( node ) ) ; describe_pnodes ( iargs ( node ) , zstr , max ) ; zs_apps ( zstr , " " ) ; break ; case IFDEFN : zs_apps ( zstr , " " ) ; break ; case IFCALL : zs_appf ( zstr , " " , ( char * ) iname ( node ) ) ; describe_pnodes ( iargs ( node ) , zstr , max ) ; zs_apps ( zstr , " " ) ; break ; case IBCALL : zs_appf ( zstr , " " , ( char * ) iname ( node ) ) ; describe_pnodes ( iargs ( node ) , zstr , max ) ; zs_apps ( zstr , " " ) ; break ; case ITRAV : zs_apps ( zstr , " " ) ; break ; case INODES : zs_apps ( zstr , " " ) ; break ; case IFAMILIES : zs_apps ( zstr , " " ) ; break ; case ISPOUSES : zs_apps ( zstr , " " ) ; break ; case ICHILDREN : zs_apps ( zstr , " " ) ; break ; case IFAMILYSPOUSES : zs_apps ( zstr , " " ) ; break ; case IINDI : zs_apps ( zstr , " " ) ; break ; case IFAM : zs_apps ( zstr , " " ) ; break ; case ISOUR : zs_apps ( zstr , " " ) ; break ; case IEVEN : zs_apps ( zstr , " " ) ; break ; case IOTHR : zs_apps ( zstr , " " ) ; break ; case ILIST : zs_apps ( zstr , " " ) ; break ; case ISET : zs_apps ( zstr , " " ) ; break ; case IFATHS : zs_apps ( zstr , " " ) ; break ; case IMOTHS : zs_apps ( zstr , " " ) ; break ; case IFAMCS : zs_apps ( zstr , " " ) ; break ; case INOTES : zs_apps ( zstr , " " ) ; break ; default : break ; } }
debug_show_one_pnode -- DEBUG routine to describe one node
  appending description into zstring
  but not more than max chars
debug_show_one_pnode -- DEBUG routine to describe one node appending description into zstring but not more than max chars