Пример #1
0
static void DumpVisitor_visitLoopStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	DUMPER(self)->indent++;
	emit_string("Loop", "", "", DUMPER(self)->indent - 1);
	handleExpr(kctx, self, Stmt_getFirstExpr(kctx, stmt));
	emit_string("Body", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getFirstBlock(kctx, stmt));
	DUMPER(self)->indent--;
}
Пример #2
0
static void DumpVisitor_visitOrExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	unsigned i;
	emit_string("OR", "", "", DUMPER(self)->indent);
	DUMPER(self)->indent++;
	for (i = 1; i < kArray_size(expr->cons); ++i) {
		handleExpr(kctx, self, kExpr_at(expr, i));
	}
	DUMPER(self)->indent--;
}
Пример #3
0
static void DumpVisitor_visitIfStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	DUMPER(self)->indent++;
	emit_string("If", "", "", DUMPER(self)->indent - 1);
	handleExpr(kctx, self, Stmt_getFirstExpr(kctx, stmt));
	emit_string("Then", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getFirstBlock(kctx, stmt));
	emit_string("Else", "", "", DUMPER(self)->indent - 1);
	visitBlock(kctx, self, Stmt_getElseBlock(kctx, stmt));
	DUMPER(self)->indent--;
}
Пример #4
0
static void DumpVisitor_visitLocalExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	char buf[128];
	snprintf(buf, 128, "LOCAL(%d, %s)", (int)expr->index, CT_t(CT_(expr->ty)));
	emit_string(buf, "", "", DUMPER(self)->indent);

}
Пример #5
0
static inline void elf_dumpreaddata(char *buffer, int buflen)
{
  uint32_t *buf32 = (uint32_t*)buffer;
  int i;
  int j;

  for (i = 0; i < buflen; i += 32)
    {
      DUMPER("%04x:", i);
      for (j = 0; j < 32; j += sizeof(uint32_t))
        {
          DUMPER("  %08x", *buf32++);
        }
      DUMPER("\n");
    }
}
Пример #6
0
static void DumpVisitor_visitReturnStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	emit_string("Return", "", "", DUMPER(self)->indent);
	kExpr* expr = Stmt_getFirstExpr(kctx, stmt);
	if(expr != NULL && IS_Expr(expr)) {
		handleExpr(kctx, self, expr);
	}
}
Пример #7
0
static void DumpVisitor_visitConstExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	KGrowingBuffer wb;
	KLIB Kwb_init(&(kctx->stack->cwb), &wb);
	KonohaStack sfp[1];
	kObject *obj = expr->objectConstValue;
	sfp[0].asObject = obj;
	O_ct(obj)->p(kctx, sfp, 0, &wb, 0);
	char  *str = (char *) KLIB Kwb_top(kctx, &wb, 0);
	char buf[128];
	snprintf(buf, 128, "CONST:%s:'%s'", CT_t(O_ct(obj)), str);
	emit_string(buf, "", "", DUMPER(self)->indent);
	KLIB Kwb_free(&wb);
}
Пример #8
0
static void DumpVisitor_visitNConstExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	KGrowingBuffer wb;
	KLIB Kwb_init(&(kctx->stack->cwb), &wb);
	KonohaStack sfp[1];
	unsigned long unboxVal = expr->unboxConstValue;
	KonohaClass *ct = CT_(expr->ty);
	sfp[0].unboxValue = unboxVal;
	ct->p(kctx, sfp, 0, &wb, 0);
	char  *str = (char *) KLIB Kwb_top(kctx, &wb, 0);
	char buf[128];
	snprintf(buf, 128, "NCONST:'%s'", str);
	emit_string(buf, "", "", DUMPER(self)->indent);
	KLIB Kwb_free(&wb);
}
Пример #9
0
static void DumpVisitor_visitLetExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	DUMPER(self)->indent++;
	emit_string("LET ", "", "", DUMPER(self)->indent);
	DUMPER(self)->indent++;
	handleExpr(kctx, self, kExpr_at(expr, 1));
	emit_string(":=", "", "", DUMPER(self)->indent);
	handleExpr(kctx, self, kExpr_at(expr, 2));
	DUMPER(self)->indent--;
	DUMPER(self)->indent--;
}
Пример #10
0
static void DumpVisitor_init(KonohaContext *kctx, struct IRBuilder *builder, kMethod *mtd)
{
	unsigned i;
	KGrowingBuffer wb;
	KLIB Kwb_init(&(kctx->stack->cwb), &wb);
	kParam *pa = Method_param(mtd);
	KLIB Kwb_printf(kctx, &wb, "METHOD %s%s(", T_mn(mtd->mn));
	for (i = 0; i < pa->psize; i++) {
		if(i != 0) {
			KLIB Kwb_write(kctx, &wb, ", ", 2);
		}
		KLIB Kwb_printf(kctx, &wb, "%s %s", TY_t(pa->paramtypeItems[i].ty), SYM_t(pa->paramtypeItems[i].fn));
	}
	emit_string(KLIB Kwb_top(kctx, &wb, 1), "", ") {", 0);
	builder->local_fields = (void *) KMalloc_UNTRACE(sizeof(int));
	DUMPER(builder)->indent = 0;
}
Пример #11
0
/* the function to dump the test db data table */
int dump_test_data(
        const char *base_path,
        struct mysql_login_info login_db_test,
        struct vmbuf *query) {

    LOGGER_INFO("dumping test_table");

    /* 'DUMPER' macro from mysql_common.h will dump the
        result of the mysql query on the 'DB_TEST' db into
        the dump 'test_table' directory */
    DUMPER(&login_db_test, DB_TEST, "test_table",
            "SELECT id, name, age FROM data;");

    /* INDEXER_O2O macro will create a one-to-one index on
       the table column 'id' in the 'test_table' dump */
    INDEXER_O2O(int32_t, DB_TEST, "test_table", "id");

    /* return 0 if dump and index were created successfully.
        Macros will return -1 if an error occurs */
    return 0;
}
Пример #12
0
static void DumpVisitor_visitCallExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	KGrowingBuffer wb;
	KLIB Kwb_init(&(kctx->stack->cwb), &wb);
	kMethod *mtd = CallExpr_getMethod(expr);
	KLIB Kwb_printf(kctx, &wb, "CALL: '%s%s'", T_mn(mtd->mn));
	DUMPER(self)->indent++;
	emit_string(KLIB Kwb_top(kctx, &wb, 1), "(", "", DUMPER(self)->indent);
	DUMPER(self)->indent++;
	unsigned i;
	for (i = 1; i < kArray_size(expr->cons); ++i) {
		handleExpr(kctx, self, kExpr_at(expr, i));
	}
	DUMPER(self)->indent--;
	emit_string(")", "", "", DUMPER(self)->indent);
	DUMPER(self)->indent--;
	KLIB Kwb_free(&wb);
}
Пример #13
0
static void DumpVisitor_visitStackTopExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	emit_string("STACKTOP", "", "", DUMPER(self)->indent);
}
Пример #14
0
static void DumpVisitor_visitBlockExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	emit_string("BLOCK", "", "", DUMPER(self)->indent);
	visitBlock(kctx, self, expr->block);
}
Пример #15
0
static void DumpVisitor_visitFieldExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	emit_string("FIELD", "", "", DUMPER(self)->indent);
}
Пример #16
0
static void DumpVisitor_visitUndefinedStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	emit_string("UNDEF", "", "", DUMPER(self)->indent);
}
Пример #17
0
static void DumpVisitor_visitErrStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt)
{
	emit_string(S_text(kStmt_getObjectNULL(kctx, stmt, KW_ERR)), "", "", DUMPER(self)->indent);
}
Пример #18
0
static void DumpVisitor_visitNullExpr(KonohaContext *kctx, IRBuilder *self, kExpr *expr)
{
	char buf[128];
	snprintf(buf, 128, "%s.NULL", CT_t(CT_(expr->ty)));
	emit_string(buf, "", "", DUMPER(self)->indent);
}