本文整理汇总了C++中print_expr函数的典型用法代码示例。如果您正苦于以下问题:C++ print_expr函数的具体用法?C++ print_expr怎么用?C++ print_expr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_expr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_binary
static void
print_binary(char *string, expr_t *expr)
{
print_expr(expr->data._binary.lvalue);
printf(" %s ", string);
print_expr(expr->data._binary.rvalue);
}
示例2: cmd_add
/* 'add' adds a message to the database, and takes two parameters:
* 'path', which is the full path to the message, and 'maildir', which
* is the maildir this message lives in (e.g. "/inbox"). response with
* an (:info ...) message with information about the newly added
* message (details: see code below)
*/
static MuError
cmd_add (ServerContext *ctx, GSList *args, GError **err)
{
unsigned docid;
const char *maildir, *path;
MuMsg *msg;
gchar *sexp;
GET_STRING_OR_ERROR_RETURN (args, "path", &path, err);
GET_STRING_OR_ERROR_RETURN (args, "maildir", &maildir, err);
docid = mu_store_add_path (ctx->store, path, maildir, err);
if (docid == MU_STORE_INVALID_DOCID)
print_and_clear_g_error (err);
else {
gchar *escpath;
escpath = mu_str_escape_c_literal (path, TRUE);
print_expr ("(:info add :path %s :docid %u)", escpath, docid);
msg = mu_store_get_msg (ctx->store, docid, err);
if (msg) {
sexp = mu_msg_to_sexp (msg, docid, NULL,
MU_MSG_OPTION_VERIFY);
print_expr ("(:update %s :move nil)", sexp);
mu_msg_unref(msg);
g_free (sexp);
}
g_free (escpath);
}
return MU_OK;
}
示例3: cons
expr cons (expr a, expr d)
{
expr c;
#ifdef TRACE
printf ("\n\t\tcons (car=");
print_expr (a);
printf (", cdr=");
print_expr (d);
printf (")...");
#endif
while (!cons_free(ptr_cons) && ptr_cons < N_CONS-1)
ptr_cons++;
if (!cons_free(ptr_cons))
gc ();
take_cons (ptr_cons);
tab_cons [ptr_cons] [0] = a;
tab_cons [ptr_cons] [1] = d;
c = (ptr_cons | 0x8000) ;
#ifdef TRACE
printf ("\n\t\tcons (car=");
print_expr (a);
printf (", cdr=");
print_expr (d);
printf (") = ");
print_expr (c);
#endif
return c;
}
示例4: print_return_type_list
static void print_return_type_list(struct return_type_list *l, int depth)
{
int i;
struct return_type *r;
if (l == NULL)
return;
printf("%sreturns\n", indent(depth));
for (i = 0, r = l->req_types; r != NULL; i++, r = r->next)
if (r->temp)
printf("%sresult %d: %s\n", indent(depth+1), i, r->temp->name);
else if (r->type) {
printf("%sresult %d:\n", indent(depth+1), i);
print_expr(r->type, depth+2);
}
else
printf("%sresult %d.\n", indent(depth+1), i);
if (l->rest_temp)
printf("%s#rest %s\n", indent(depth+1), l->rest_temp->name);
else if (l->rest_type) {
printf("%s#rest\n", indent(depth+1));
print_expr(l->rest_type, depth+2);
}
else if (l->restp)
printf("%s#rest foo :: <object>\n", indent(depth+1));
printf("%send returns\n", indent(depth));
}
示例5: gen_expr_str_funcall
void gen_expr_str_funcall(expr *e, symtable *stab)
{
expr **iter;
(void)stab;
idt_printf("funcall, calling:\n");
gen_str_indent++;
print_expr(e->expr);
gen_str_indent--;
if(e->funcargs){
int i;
idt_printf("args:\n");
gen_str_indent++;
for(i = 1, iter = e->funcargs; *iter; iter++, i++){
idt_printf("arg %d:\n", i);
gen_str_indent++;
print_expr(*iter);
gen_str_indent--;
}
gen_str_indent--;
}else{
idt_printf("no args\n");
}
}
示例6: print_dot_expr
static void print_dot_expr(struct dot_expr *e, int depth)
{
printf("%sdot operator\n%sargument\n", indent(depth), indent(depth+1));
print_expr(e->arg, depth+2);
printf("%sfunction\n", indent(depth+1));
print_expr(e->func, depth+2);
printf("%send dot operator\n", indent(depth));
}
示例7: print_arg
/* generate code from function call arguments*/
int print_arg(Expr expr, int reg, char* proc_id,
int paramNum,char* callee) {
int curr_reg = reg;
int next_reg;
int ID_type;
int ID_type2;
switch (expr->kind) {
Type ID_type;
int stackNo;
case EXPR_ID:
ID_type = getType(proc_id,expr->id);
stackNo = getStackSlotNum(proc_id, expr->id);
if(isParamRef(callee,paramNum)==0){
printf("load r%d, %d\n", curr_reg,stackNo);
}
if(isParamRef(callee,paramNum)==1){
if(isRef(proc_id, expr->id)==1)
printf("load r%d, %d\n", curr_reg,stackNo);
else
printf("load_address r%d, %d\n", curr_reg,stackNo);
}
break;
case EXPR_CONST:
print_constant(expr->constant, curr_reg);
break;
case EXPR_BINOP:
ID_type = getExprType(expr->e1, proc_id);
ID_type2 = getExprType(expr->e2, proc_id);
curr_reg = print_expr(expr->e1, curr_reg, proc_id);
next_reg = print_expr(expr->e2, curr_reg + 1, proc_id);
print_binop_string(expr->binop, curr_reg,
next_reg, ID_type, ID_type2);
break;
case EXPR_RELOP:
ID_type = getExprType(expr->e1, proc_id);
ID_type2 = getExprType(expr->e2, proc_id);
curr_reg = print_expr(expr->e1, curr_reg, proc_id);
next_reg = print_expr(expr->e2, curr_reg + 1, proc_id);
print_relop_string(expr->relop, curr_reg,
next_reg, ID_type, ID_type2);
break;
case EXPR_UNOP:
ID_type = getExprType(expr->e1, proc_id);
print_unop_string(expr->unop, curr_reg, ID_type);
break;
}
if(getExprType(expr,proc_id) != getParamType(callee,paramNum)){
//printf("%d,%d ",getExprType(expr), getParamType(callee,paramNum));
printf("int_to_real r%d, r%d\n", curr_reg,curr_reg);
}
return curr_reg;
}
示例8: print_comma_list
static void
print_comma_list(expr_t *expr)
{
print_expr(expr);
if (expr) {
for (expr = expr->next; expr; expr = expr->next) {
printf(" , ");
print_expr(expr);
}
}
}
示例9: print_select_expr
static void print_select_expr(struct select_expr *e, int depth)
{
printf("%sselect\n", indent(depth));
print_expr(e->expr, depth+1);
if (e->by) {
printf("%sby\n", indent(depth));
print_expr(e->by, depth+1);
}
print_condition_body(e->body, depth);
printf("%send select\n", indent(depth));
}
示例10: print_binop_series_expr
static void print_binop_series_expr(struct binop_series_expr *e, int depth)
{
struct binop *b;
printf("%sbinop series\n", indent(depth));
print_expr(e->first_operand, depth+1);
for (b = e->first_binop; b != NULL; b = b->next) {
printf("%sbinop %s\n", indent(depth), b->op->symbol->name);
print_expr(b->operand, depth+1);
}
printf("%send binop series\n", indent(depth));
}
示例11: print_call_expr
static void print_call_expr(struct call_expr *e, int depth)
{
int i;
struct argument *arg;
printf("%scall\n%sfunction:\n", indent(depth), indent(depth+1));
print_expr(e->func, depth+2);
for (i = 0, arg = e->args; arg != NULL; i++, arg = arg->next) {
printf("%sargument %d\n", indent(depth+1), i);
print_expr(arg->expr, depth+2);
}
printf("%send call\n", indent(depth));
}
示例12: repl
void repl() {
char *input;
while ((input = readline("> ")) != NULL) {
int ss = stack_size;
read_start:;
#ifdef READLINE
if (input && *input)
add_history(input);
#endif
const char *p = input;
error err;
atom expr;
err = read_expr(p, &p, &expr);
if (err == ERROR_FILE) { /* read more lines */
char *line = readline(" ");
if (!line) break;
input = strcat_alloc(&input, "\n");
input = strcat_alloc(&input, line);
free(line);
goto read_start;
}
if (!err) {
while (1) {
atom result;
error err = macex_eval(expr, &result);
if (err) {
print_error(err);
printf("error in expression:\n");
print_expr(expr);
putchar('\n');
break;
}
else {
print_expr(result);
puts("");
}
err = read_expr(p, &p, &expr);
if (err != ERROR_OK) {
break;
}
}
} else {
print_error(err);
}
stack_restore(ss);
free(input);
}
}
示例13: print_defclass_constituent
static void
print_defclass_constituent(struct defclass_constituent *c, int depth)
{
static char *alloc[] = {"instance", "class", "each-subclass",
"constant", "virtual"};
struct superclass *super;
struct slot_spec *slot;
struct initarg_spec *initarg;
struct inherited_spec *inherited;
printf("%sdefine class\n", indent(depth));
printf("%sname: %s\n", indent(depth+1), c->name->symbol->name);
if (c->tlf1) {
printf("%sphase 1:\n", indent(depth+1));
print_method(c->tlf1, depth+2);
printf("%sphase 2:\n", indent(depth+1));
print_method(c->tlf2, depth+2);
}
else {
printf("%ssupers:\n", indent(depth+1));
for (super = c->supers; super != NULL; super = super->next)
print_expr(super->expr, depth+2);
printf("%sslots:\n", indent(depth+1));
for (slot = c->slots; slot != NULL; slot = slot->next) {
printf("%s%s slot, %s allocation\n", indent(depth+2),
slot->name ? (char*)slot->name->symbol->name : "anonymous",
alloc[(int)slot->alloc]);
if (slot->type) {
printf("%stype:\n", indent(depth+2));
print_expr(slot->type, depth+3);
}
print_plist(slot->plist, depth+2);
}
printf("%sinitialization arguments:\n", indent(depth+1));
for (initarg = c->initargs; initarg != NULL;
initarg = initarg->next) {
printf("%s%s%s initarg\n", indent(depth+2),
initarg->keyword->name,
initarg->required ? " required " : "");
print_plist(initarg->plist, depth+2);
}
printf("%sinherited slots:\n", indent(depth+1));
for (inherited = c->inheriteds; inherited != NULL;
inherited = inherited->next) {
printf("%s%s inherited slot\n", indent(depth+2),
inherited->name->symbol->name);
print_plist(inherited->plist, depth+2);
}
}
printf("%send define class\n", indent(depth));
}
示例14: print_assign
/*
Non-array assignment
*/
void print_assign(Assign assign, char* proc_id) {
int ID_type;
int expr_type;
int slot;
int reg = 0;
ID_type = getType(proc_id,assign.id);
expr_type = getExprType(assign.expr, proc_id);
if (isRef(proc_id, assign.id)==0){
if (ID_type == 2 && expr_type == 1){
slot = getStackSlotNum(proc_id, assign.id);
printf("#assignment\n");
print_expr(assign.expr, 0, proc_id);
printf("int_to_real r0, r0\n");
printf("store %d, r0\n", slot);
printf("\n");
}
else if ((ID_type == 1 && expr_type == 1) ||
(ID_type == 2 && expr_type == 2) ||
(ID_type == 0 && expr_type == 0)){
slot = getStackSlotNum(proc_id, assign.id);
printf("#assignment\n");
print_expr(assign.expr, 0, proc_id);
printf("store %d, r0\n", slot);
printf("\n");
}
}
else if(isRef(proc_id, assign.id)==1){
if (ID_type == 2 && expr_type == 1){
slot = getStackSlotNum(proc_id, assign.id);
printf("#assignment\n");
print_expr(assign.expr, reg, proc_id);
printf("int_to_real r0, r0\n");
printf("load r1, %d\n", slot);
printf("store_indirect r1, r%d\n", reg);
printf("\n");
}
else if ((ID_type == 1 && expr_type == 1) ||
(ID_type == 2 && expr_type == 2) ||
(ID_type == 0 && expr_type == 0)){
slot = getStackSlotNum(proc_id, assign.id);
printf("#assignment\n");
print_expr(assign.expr, reg, proc_id);
printf("load r1, %d\n", slot);
printf("store_indirect r1, r%d\n", reg);
printf("\n");
}
}
}
示例15: print_handler_constituent
static void print_handler_constituent(struct handler_constituent *c, int depth)
{
printf("%shandler\n", indent(depth));
if (c->type) {
printf("%stype:\n", indent(depth+1));
print_expr(c->type, depth+2);
printf("%sfunction:\n", indent(depth+1));
print_expr(c->func, depth+2);
print_plist(c->plist, depth+1);
}
printf("%sbody\n", indent(depth));
print_body(c->body, depth+1);
printf("%send handler\n", indent(depth));
}