예제 #1
0
int main(int argc, char **argv) {
     progname = argv[0];

     buf_init(module, INIT_MODS, 1, struct _module, "modules");
     buf_init(dep, INIT_MODS, 1, int, "dependencies");

     stack_size = STACK_SIZE;

     get_options(argc, argv);
     if (nfiles == 0 && !dump) panic("no input files");
     if (stdlib && libdir == NULL) panic("no libdir specified");
     if (rtlibdir == NULL) rtlibdir = libdir;

     make_prim("INTERP");
     make_prim("DLTRAP");
     
#define bind(x) def_global(find_symbol(#x), ABS, x, X_SYM)

     bind(GC_BASE); bind(GC_REPEAT); bind(GC_BLOCK);
     bind(GC_MAP); bind(GC_FLEX); bind(GC_END);
     bind(E_CAST); bind(E_ASSIGN); bind(E_CASE);
     bind(E_WITH); bind(E_ASSERT); bind(E_RETURN);
     bind(E_BOUND); bind(E_NULL); bind(E_DIV);
     bind(E_FDIV); bind(E_STACK); bind(E_GLOB);

     /* First pass -- check for dependencies */
     scan_files();

     /* Compute needed modules */
     buf_grow(module);
     module[nmodules].m_dep = ndeps;
     trace_imports();

     if (status != 0) return status;

     /* Second pass -- link the modules that are needed */
     if (!dump) {
	  init_linker(outname, interp);
	  load_needed();
	  gen_main();
	  if (rtlibdir != NULL)
	       save_string("LIBDIR", rtlibdir);
	  end_linking();
     }

     if (dump || custom) {
	  printf("/* Primitive table -- generated by oblink */\n\n");
	  printf("#include \"obx.h\"\n\n");
	  dump_prims(stdout);
     }

     return status;
}
예제 #2
0
파일: ex.c 프로젝트: ganmacs/playground
void create() {
  static int id = 1;
  Thread* t = (Thread*)malloc(sizeof(Thread));
  t->id = id++;
  jmp_buf* buf = (jmp_buf*)malloc(sizeof(jmp_buf));
  t->context = buf;
  make_prim(buf, t->id);

  Thread* tmp;
  tmp = threadList;
  threadList = t;
  threadList->next = tmp;
}
예제 #3
0
static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmode, unsigned int layer, 
		int type, int tot, int seg,
		int subdiv, float dia, float depth, int ext, int fill)
{
	Object *obedit= CTX_data_edit_object(C);
	int newob = 0;
	float mat[4][4];
	float scale;

	if(obedit==NULL || obedit->type!=OB_MESH) {
		obedit= ED_object_add_type(C, OB_MESH, loc, rot, FALSE, layer);
		
		rename_id((ID *)obedit, get_mesh_defname(type));
		rename_id((ID *)obedit->data, get_mesh_defname(type));
		
		/* create editmode */
		ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
		newob = 1;
	}
	else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);

	scale= ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);

	dia *= scale;
	depth *= scale * 0.5f;

	make_prim(obedit, type, mat, tot, seg, subdiv, dia, depth, ext, fill);

	DAG_id_tag_update(obedit->data, 0);
	WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);


	/* userdef */
	if (newob && !enter_editmode) {
		ED_object_exit_editmode(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */
	}
	WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
}
예제 #4
0
/* scan -- scan a file for MODULE and IMPORT directives */
static void scan(char *name, boolean islib)  {
     FILE *fp;
     int m = -1, m2, chksum;

     err_file = must_strdup(name);
     fp = fopen(name, "r");
     if (fp == NULL) {
	  perror(name);
	  exit(2);
     }

     while (fgets(line, MAXLINE, fp) != NULL) {
	  nwords = split_line(line, words);
	  if (nwords == 0) continue;

	  if (strcmp(words[0], "MODULE") == 0) {
	       char *mname = words[1];
	       m = find_module(mname);
	       if (m >= 0) {
		    if (module[m].m_lib)
			 error("%s has the same name as a library module", 
			       words[1]);
		    else 
			 error("%s is loaded more than once", words[1]);
	       }
	       
	       buf_grow(module);
	       m = nmodules;
	       module[m].m_file = name;
	       module[m].m_name = must_strdup(mname);
	       module[m].m_lib = islib;
	       module[m].m_needed = FALSE;
	       module[m].m_dep = ndeps;
	       module[m].m_check = strtoul(words[2], NULL, 0);
	       nmodules++;
	  } else if (strcmp(words[0], "IMPORT") == 0) {
	       if (m < 0)
		    error("IMPORT appears before MODULE in %s", name);

	       m2 = find_module(words[1]);
	       chksum = strtoul(words[2], NULL, 0);
	       buf_grow(dep);
	       if (m2 < 0) 
		    error("%s imports %s -- please load it first",
			  module[m].m_name, words[1]);
	       else {
		    dep[ndeps++] = m2;
		    if (module[m2].m_check != chksum)
			 error("checksum of module %s does not match value"
			       " expected by module %s", 
			       words[1], module[m].m_name);
	       }
	  } else if (strcmp(words[0], "PRIM") == 0) {
	       if (islib && !custom
#ifdef DYNLINK
		   && *words[1] != '*'
#endif
		    ) make_prim(words[1]);
	  } else if (strcmp(words[0], "ENDHDR") == 0) {
	       break;
	  } else {
	       panic("*bad directive %s in file header", words[0]);
	  }
     }

     fclose(fp);
}