Exemplo n.º 1
0
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv)
{
    if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
        return false;

    rtStats->gcHeapChunkTotal =
        size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;

    rtStats->gcHeapUnusedChunks =
        size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize;

    // This just computes rtStats->gcHeapDecommittedArenas.
    IterateChunks(rt, rtStats, StatsChunkCallback);

    // Take the per-compartment measurements.
    IteratorClosure closure(rtStats, opv);
    if (!closure.init())
        return false;
    rtStats->runtime.scriptSources = 0;
    IterateCompartmentsArenasCells(rt, &closure, StatsCompartmentCallback,
                                   StatsArenaCallback, StatsCellCallback);

    // Take the "explicit/js/runtime/" measurements.
    rt->sizeOfIncludingThis(rtStats->mallocSizeOf, &rtStats->runtime);

    rtStats->gcHeapGcThings = 0;
    for (size_t i = 0; i < rtStats->compartmentStatsVector.length(); i++) {
        CompartmentStats &cStats = rtStats->compartmentStatsVector[i];

        rtStats->totals.add(cStats);
        rtStats->gcHeapGcThings += cStats.gcHeapThingsSize();
    }

    size_t numDirtyChunks =
        (rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
    size_t perChunkAdmin =
        sizeof(gc::Chunk) - (sizeof(gc::Arena) * gc::ArenasPerChunk);
    rtStats->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;
    rtStats->gcHeapUnusedArenas -= rtStats->gcHeapChunkAdmin;

    // |gcHeapUnusedArenas| is the only thing left.  Compute it in terms of
    // all the others.  See the comment in RuntimeStats for explanation.
    rtStats->gcHeapUnusedArenas = rtStats->gcHeapChunkTotal -
                                  rtStats->gcHeapDecommittedArenas -
                                  rtStats->gcHeapUnusedChunks -
                                  rtStats->totals.gcHeapUnusedGcThings -
                                  rtStats->gcHeapChunkAdmin -
                                  rtStats->totals.gcHeapArenaAdmin -
                                  rtStats->gcHeapGcThings;
    return true;
}
Exemplo n.º 2
0
void CFG::constructCanonicalLR0Collection()
{
	if(!augmented)
	{
		augmentGrammar();
	}

	canonicalLR0Collection.clear();

	canonicalLR0Collection = vector<vector<LR0Item>>(
	{
		closure(
			vector<LR0Item>(
			{
				LR0Item(
					find_if(
						p.begin(), 
						p.end(),
						[this](const Production& pr)
						{
							return pr.left == s; 
						}
					) - p.begin(),
					0
				)
			})
		)
	});

	bool updated = false;
	vector<string> symbols = v;
	symbols.insert(symbols.end(), t.begin(), t.end());

	do
	{
		updated = false;

		for(size_t i = 0; i < canonicalLR0Collection.size(); ++i)
		{
			for(size_t j = 0; j < symbols.size(); ++j)
			{
				vector<LR0Item> goToIX = goTo(canonicalLR0Collection[i], symbols[j]);
				if(goToIX.size() != 0 && !in(goToIX, canonicalLR0Collection))
				{
					canonicalLR0Collection.push_back(goToIX);
					updated = true;
				}
			}
		}
	}while(updated);
}
Exemplo n.º 3
0
static void
print_core (FILE *out, state *s)
{
  size_t i;
  item_number *sitems = s->items;
  size_t snritems = s->nitems;
  symbol *previous_lhs = NULL;

  /* Output all the items of a state, not only its kernel.  */
  if (report_flag & report_itemsets)
    {
      closure (sitems, snritems);
      sitems = itemset;
      snritems = nitemset;
    }

  if (!snritems)
    return;

  fputc ('\n', out);

  for (i = 0; i < snritems; i++)
    {
      item_number *sp;
      item_number *sp1;
      rule_number r;

      sp1 = sp = ritem + sitems[i];

      while (*sp >= 0)
	sp++;

      r = item_number_as_rule_number (*sp);

      rule_lhs_print (&rules[r], previous_lhs, out);
      previous_lhs = rules[r].lhs;

      for (sp = rules[r].rhs; sp < sp1; sp++)
	fprintf (out, " %s", symbols[*sp]->tag);
      fputs (" .", out);
      for (/* Nothing */; *sp >= 0; ++sp)
	fprintf (out, " %s", symbols[*sp]->tag);

      /* Display the lookahead tokens?  */
      if (report_flag & report_lookahead_tokens
          && item_number_is_rule_number (*sp1))
	state_rule_lookahead_tokens_print (s, &rules[r], out);

      fputc ('\n', out);
    }
}
Exemplo n.º 4
0
struct cons_t* environment_t::define(const std::string& name, lambda_t f, bool syntactic)
{
  /*
   * TODO: Are redefinitions legal?
   */
  bool warn_mul_defs = false;

  if ( warn_mul_defs )
    fprintf(stderr, "WARNING: Already have a definition for %s\n",
      name.c_str());

  symbols[name] = closure(f, this, syntactic);
  return symbols[name];
}
Exemplo n.º 5
0
/*
 * @NAME: collection_any_satisfy2
 * @DESC: Igual a funcion any_satisfy de Haskell
 */
bool collection_any_satisfy2( t_list* list, char (*closure)(void*, ...),...){
	va_list args_list;
	va_start(args_list,*closure);
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		if(closure(element->data, args_list)){
			return(1);
		}
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(0);
}
Exemplo n.º 6
0
void CLRItemCollectionFamily::build(const BNFInstance& bnf)
{
    for (auto &sym : bnf.symbolSet) {
        if (sym.type == SyntaxSymbol::T_Terminal) {
            term2ID[sym.value] = (int)ID2Term.size();
            ID2Term.push_back(sym.value);
        }
    }

    vector<int> unhanldedState;
    {
        CLRItemCollection col;
        CLRItem item = {0, 0, term2ID[END_TERM]};
        col.items.insert(item.toInt());
        closure(bnf, col);
        int ns;
        addCollection(col, ns);
        unhanldedState.push_back(0);
    }
    while (!unhanldedState.empty()) {
        int state = unhanldedState.back();
        unhanldedState.pop_back();
        for (auto &sym : bnf.symbolSet) {
            const CLRItemCollection& col(ID2Collection[state]);
            CLRItemCollection newCol;
            transToNewItemCollection(bnf, col, newCol, sym);
            closure(bnf, newCol);
            if (!newCol.items.empty()) {
                int ns;
                if (addCollection(newCol, ns)) {
                    unhanldedState.push_back(ns);
                }
                dfa[state][sym] = ns;
            }
        }
    }
}
Exemplo n.º 7
0
//----------------------------------------------------------------------
// 構造体比較関数
tTJSVariant
ScriptsAdd::clone(tTJSVariant obj)
{
	// タイプがオブジェクトなら細かく判定
	if (obj.Type() == tvtObject) {

		tTJSVariantClosure &o1 = obj.AsObjectClosureNoAddRef();
		
		// Arrayの複製
		if (o1.IsInstanceOf(0, NULL, NULL, L"Array", NULL)== TJS_S_TRUE) {
			iTJSDispatch2 *array = TJSCreateArrayObject();
			tTJSVariant o1Count;
			(void)o1.PropGet(0, L"count", &countHint, &o1Count, NULL);
			tjs_int count = o1Count;
			tTJSVariant val;
			tTJSVariant *args[] = {&val};
			for (tjs_int i = 0; i < count; i++) {
				(void)o1.PropGetByNum(TJS_IGNOREPROP, i, &val, NULL);
				val = ScriptsAdd::clone(val);
				static tjs_uint addHint = 0;
				(void)array->FuncCall(0, TJS_W("add"), &addHint, 0, 1, args, array);
			}
			tTJSVariant result(array, array);
			array->Release();
			return result;
		}
		
		// Dictionaryの複製
		if (o1.IsInstanceOf(0, NULL, NULL, L"Dictionary", NULL)== TJS_S_TRUE) {
			iTJSDispatch2 *dict = TJSCreateDictionaryObject();
			DictMemberCloneCaller *caller = new DictMemberCloneCaller(dict);
			tTJSVariantClosure closure(caller);
			o1.EnumMembers(TJS_IGNOREPROP, &closure, NULL);
			caller->Release();
			tTJSVariant result(dict, dict);
			dict->Release();
			return result;
		}

		// cloneメソッドの呼び出しに成功すればそれを返す
		tTJSVariant result;
		static tjs_uint cloneHint = 0;
		if (o1.FuncCall(0, L"clone", &cloneHint, &result, 0, NULL, NULL)== TJS_S_TRUE) {
			return result;
		}
	}
	
	return obj;
}
Exemplo n.º 8
0
vector<const pddl_type *> TypeHierarchy::accumulateAll(const pddl_type * t)
{
	vector<const pddl_type *> nds(1,t);
	PTypeRef tt(t);
	GI gi = downGraph.find(&tt);
	if(gi == downGraph.end()) return nds;
	Nodes ns;
	PTypeRef pt(0);
	closure(downGraph,gi,ns,gi,&pt);
	for(Nodes::const_iterator i = ns.begin();i != ns.end();++i)
	{
		nds.push_back(***i);
	};
	return nds;
};
Exemplo n.º 9
0
/**
 * Replace closure that point to oldEnv with closure on newEnv
 */
static void updateClosures(vector<Tree>& clos, Tree oldEnv, Tree newEnv)
{
  for(unsigned int i = 0; i < clos.size(); i++)
  {
    Tree exp, genv, visited, lenv;

    if(isClosure(clos[i], exp, genv, visited, lenv))
    {
      if(lenv == oldEnv)
      {
        clos[i] = closure(exp, genv, visited, newEnv);
      }
    }
  }
}
Exemplo n.º 10
0
/*
 * @NAME: collection_filter
 * @DESC: Igual a la funcion filter de haskell
 */
void *collection_filter( t_list* list, char (*closure)(void*, void*),void *arg){
	t_list *listaAux=collection_list_create();
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		if(closure(element->data, arg)){
			void *newData=malloc(sizeof(element->data));
			memcpy(newData,element->data,sizeof(element->data));
			//newData=element->data;
			collection_list_add(listaAux,newData);
		}
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(listaAux);
}
Exemplo n.º 11
0
/*
 * @NAME: collection_map2
 * @DESC: Igual a la funcion map de haskell pero con argumentos variables
 */
void *collection_map2( t_list* list, void *(*closure)(void*, ...),...){
	va_list args_list;
	va_start(args_list,*closure);
	t_list *listaAux=collection_list_create();
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		void *newData=malloc(sizeof(*closure));
		//newData=closure(element->data, args_list);
		memcpy(newData,closure(element->data, args_list),sizeof(*closure));
		collection_list_add(listaAux,newData);
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(listaAux);
}
Exemplo n.º 12
0
void closure( const Entity & e_from , std::vector<Entity*> & eset )
{
  PairIterRelation rel = e_from.relations();
  for ( ; rel ; ++rel ) {
    if ( rel->forward() ) {
      Entity * const e = rel->entity();
      std::vector<Entity*>::iterator i = eset.begin();
      std::vector<Entity*>::iterator j = eset.end();
      i = std::lower_bound( i , j , e , LessEntityPointer() );
      if ( i == j || e != *i ) {
        eset.push_back( e );
        closure( *e , eset );
      }
    }
  }
}
Exemplo n.º 13
0
bool	GR_CocoaImage::convertFromBuffer(const UT_ByteBuf* pBB, const std::string & mimetype, 
                                         UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight)
{
	const char *buffer = (const char *) pBB->getPointer(0);
	UT_uint32 buflen = pBB->getLength();


	if(mimetype == "image/png") {

		if (buflen < 6) {
			return false;
		}

		char str1[10] = "\211PNG";
		char str2[10] = "<89>PNG";

		if ( !(strncmp(buffer, str1, 4)) || !(strncmp(buffer, str2, 6)) )
		{
			m_grtype = GRT_Raster;
			if(m_surface) {
				cairo_surface_destroy(m_surface);
			}
			
			_PNG_read_state closure(pBB);
			m_surface = cairo_image_surface_create_from_png_stream (&_UT_ByteBuf_PNG_read, &closure);
			if(CAIRO_SURFACE_TYPE_IMAGE == cairo_surface_get_type(m_surface)) 
			{
				if((cairo_image_surface_get_width(m_surface) != iDisplayWidth) ||
					(cairo_image_surface_get_height(m_surface) != iDisplayHeight)) {
					// needs resize.
					
					cairo_surface_t *rescaled = _rescaleTo(m_surface, iDisplayWidth, iDisplayHeight);
					cairo_surface_destroy(m_surface);
					m_surface = rescaled;
				}
			}
			setDisplaySize(iDisplayWidth, iDisplayHeight);
			return true;
		}
	}
	// Otherwise, assume SVG. Do scaling when drawing; save size for then:
	m_grtype = GRT_Vector;

	setDisplaySize(iDisplayWidth, iDisplayHeight);

	return true;
}
Exemplo n.º 14
0
vector<LR0Item> CFG::goTo(const vector<LR0Item>& is, const string& x)
{
	vector<LR0Item> js;

	for(size_t i = 0; i < is.size(); ++i)
	{
		Production pr = p[is[i].productionIndex];
		if(!(pr.right.size() == 1 && pr.right[0] == "")
			&& is[i].dotPosition < pr.right.size()
			&& pr.right[is[i].dotPosition] == x)
		{
			js.push_back(LR0Item(is[i].productionIndex, is[i].dotPosition + 1));
		}
	}
	
	return closure(js);
}
Exemplo n.º 15
0
	/**
	 * メンバ名一覧の取得
	 */
tjs_error TJS_INTF_METHOD
ScriptsAdd::getKeys(tTJSVariant *result,
					tjs_int numparams,
					tTJSVariant **param,
					iTJSDispatch2 *objthis)
{
	if (numparams < 1) return TJS_E_BADPARAMCOUNT;
	if (result) {
		iTJSDispatch2 *array = TJSCreateArrayObject();
		DictMemberGetCaller *caller = new DictMemberGetCaller(array);
		tTJSVariantClosure closure(caller);
		param[0]->AsObjectClosureNoAddRef().EnumMembers(TJS_IGNOREPROP, &closure, NULL);
		caller->Release();
		*result = tTJSVariant(array, array);
		array->Release();
	}
	return TJS_S_OK;
}
Exemplo n.º 16
0
//----------------------------------------------------------------
string prawyArgument(const string & text)
{
	if(text.empty())
	{
		return "";
	}

	if(text[0] == '(')
	{
		size_t pozycja = closure(text, 0);
		return text.substr(0, pozycja);
	}
	else
	{
		size_t pozycja = text.find_first_of("*/+-()");
		return text.substr(0, pozycja - 1);
	}
}
Exemplo n.º 17
0
/**
 * 吉里吉里クラスから Javascript クラスを生成
 * @param args 引数
 * @return 結果
 */
void
TJSInstance::createTJSClass(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	if (args.Length() < 1) {
		args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "invalid param")));
		return;
	}

	// TJSクラス情報取得
	String::Value tjsClassName(args[0]);
	tTJSVariant tjsClassObj;
	TVPExecuteExpression(*tjsClassName, &tjsClassObj);
	if (tjsClassObj.Type() != tvtObject || TJS_FAILED(tjsClassObj.AsObjectClosureNoAddRef().IsInstanceOf(0,NULL,NULL,L"Class",NULL))) {
		args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "invalid param")));
		return;
	}
	
	// クラステンプレートを生成
	Local<FunctionTemplate> classTemplate = FunctionTemplate::New(isolate, tjsConstructor, TJSObject::toJSObject(isolate, tjsClassObj));
	classTemplate->SetClassName(args[0]->ToString()); // 表示名
	
	// メンバ登録処理
	for (int i=args.Length()-1;i>=0;i--) {
		String::Value className(args[i]);
		tTJSVariant classObj;
		TVPExecuteExpression(*className, &classObj);
		if (classObj.Type() == tvtObject &&
			TJS_SUCCEEDED(classObj.AsObjectClosureNoAddRef().IsInstanceOf(0,NULL,NULL,L"Class",NULL))) {
			MemberRegister *caller = new MemberRegister(isolate, classTemplate);
			tTJSVariantClosure closure(caller);
			classObj.AsObjectClosureNoAddRef().EnumMembers(TJS_IGNOREPROP, &closure, NULL);
			caller->Release();
		}
	}

	// TJS機能メソッドを登録
	Local<ObjectTemplate> protoTemplate = classTemplate->PrototypeTemplate();
	protoTemplate->Set(String::NewFromUtf8(isolate, "tjsIsValid"), FunctionTemplate::New(isolate, tjsIsValid));
	protoTemplate->Set(String::NewFromUtf8(isolate, "tjsOverride"), FunctionTemplate::New(isolate, tjsOverride));
	
	args.GetReturnValue().Set(classTemplate->GetFunction());
}
void Dfa::tr_nfa_to_dfa(const Nfa &nfa){
    State start_state;
    closure(nfa.get_start(), start_state, true);
    auto start_hash_code = hash_code(start_state);

    map<HashCodeType, State*> node_set_map;
    map<HashCodeType, Node*> node_map;
    queue<HashCodeType> node_set_queue;
    node_set_map[start_hash_code] = &start_state;
    node_map[start_hash_code] = new Node();
    node_set_queue.push(start_hash_code);

    while(!node_set_queue.empty()){
        auto code_now = node_set_queue.front();
        node_set_queue.pop();
        auto set_now = node_set_map[code_now];
        auto node_now = node_map[code_now];

        for(char path_char=PATH_BEGIN;path_char<PATH_END;++path_char){
            auto set_next = new State();
            next(*set_now, *set_next, path_char);
            if(set_next->size() == 0) continue;
            auto code_next = hash_code(*set_next);

            bool is_new_set = false;
            if(node_map.end() == node_map.find(code_next)){
                node_map[code_next] = new Node(contain_end_node(*set_next));
                node_set_map[code_next] = set_next;
                node_set_queue.push(code_next);
                is_new_set = true;
            }

            auto node_next = node_map[code_next];
            node_now->set_path(node_next, path_char);

            if(!is_new_set){
                safe_delete(set_next);
            }
        }
    }

    _start = node_map[start_hash_code];
}
Exemplo n.º 19
0
void closure(int nfa[][20],int k,int n)
{
	int i,d;
	for(i=0;i<=n;i++)
	{
		d=nfa[k][i];
		if(d==1)
		{
			if(i!=k)
			{
				closure(nfa,i,n);
			}
			else
			{
				printf("[%d]",i+1);
			}
		}
	}	
}
Exemplo n.º 20
0
int main()
{
	FSM* fsm = concat(closure(alternative(createCharacter('a'), 
										  createCharacter('b'))),
					  concat(createCharacter('a'), 
							 concat(createCharacter('b'), createCharacter('b'))));
	printFsm(fsm);
	char buffer[100];
	do {
		printf("String: ");
		scanf("%s", buffer);
		if (simulate(fsm, buffer)) {
			printf("%s wurde akzeptiert.\n", buffer);
		} else {
			printf("%s wurde nicht akzeptiert.\n", buffer);
		}
	} while (buffer[1]);
	freeFsm(fsm);
}
Exemplo n.º 21
0
void
generate_states (void)
{
  item_number initial_core = 0;
  state_list *list = NULL;
  allocate_storage ();
  new_closure (nritems);

  /* Create the initial state.  The 0 at the lhs is the index of the
     item of this initial rule.  */
  state_list_append (0, 1, &initial_core);

  /* States are queued when they are created; process them all.  */
  for (list = first_state; list; list = list->next)
    {
      state *s = list->state;
      if (trace_flag & trace_automaton)
	fprintf (stderr, "Processing state %d (reached by %s)\n",
		 s->number,
		 symbols[s->accessing_symbol]->tag);
      /* Set up itemset for the transitions out of this state.  itemset gets a
         vector of all the items that could be accepted next.  */
      closure (s->items, s->nitems);
      /* Record the reductions allowed out of this state.  */
      save_reductions (s);
      /* Find the itemsets of the states that shifts can reach.  */
      new_itemsets (s);
      /* Find or create the core structures for those states.  */
      append_states (s);

      /* Create the shifts structures for the shifts to those states,
	 now that the state numbers transitioning to are known.  */
      state_transitions_set (s, nshifts, shiftset);
    }

  /* discard various storage */
  free_closure ();
  free_storage ();

  /* Set up STATES. */
  set_states ();
}
Exemplo n.º 22
0
static void generate_states(void) {
    allocate_storage();
    itemset = NEW2(nitems, Value_t);
    ruleset = NEW2(WORDSIZE(nrules), unsigned);
    set_first_derives();
    initialize_states();

    while (this_state) {
        closure(this_state->items, this_state->nitems);
        save_reductions();
        new_itemsets();
        append_states();

        if (nshifts > 0)
            save_shifts();

        this_state = this_state->next;
    }

    free_storage();
}
Exemplo n.º 23
0
/*
 * @NAME: collection_filter2
 * @DESC: Igual a la funcion filter de haskell con argumentos variables
 */
void *collection_filter2( t_list* list, char (*closure)(void*, ...),...){
	va_list args_list;
	va_start(args_list,*closure);
	t_list *listaAux=collection_list_create();
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		if(closure(element->data, args_list)){
			//unsigned long *a;
			//a=element->data;
			void *newData=malloc(sizeof(element->data));
			memcpy(newData,element->data,sizeof(element->data));//Si pasara pos donde apuntan punteros seria mas liviano
			//printf("Añado el sector ** %ld ** a la lista\n",*a);
			//newData=element->data;
			collection_list_add(listaAux,newData);
		}
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(listaAux);
}
Exemplo n.º 24
0
void
graph(void)
{
    int i;
    int j;
    shifts *sp;
    int sn;
    int as;

    if (!gflag)
	return;

    for (i = 0; i < nstates; ++i)
    {
	closure(state_table[i]->items, state_table[i]->nitems);
	graph_state(i);
    }

    fprintf(graph_file, "\n\n");
    for (i = 0; i < nstates; ++i)
    {

	sp = shift_table[i];
	if (sp)
	    for (j = 0; j < sp->nshifts; ++j)
	    {
		sn = sp->shift[j];
		as = accessing_symbol[sn];
		fprintf(graph_file,
			"\tq%d -> q%d [label=\"%s\"];\n",
			i, sn, symbol_pname[as]);
	    }
    }

    fprintf(graph_file, "}\n");

    for (i = 0; i < nsyms; ++i)
	FREE(symbol_pname[i]);
    FREE(symbol_pname);
}
Exemplo n.º 25
0
bool	GR_CocoaImage::convertFromBuffer(const UT_ByteBuf* pBB, const std::string & mimetype, 
                                         UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight)
{
	const char *buffer = (const char *) pBB->getPointer(0);
	UT_uint32 buflen = pBB->getLength();


	// We explicitely do not scale the image on load, since cairo can do
	// that during rendering. Scaling during loading will result in lost
	// image information, which in turns results in bugs like
	// in bugs like #12183.
	// So simply remember the display size for drawing later.
	setDisplaySize(iDisplayWidth, iDisplayHeight);

	if(mimetype == "image/png") {

		if (buflen < 6) {
			return false;
		}

		char str1[10] = "\211PNG";
		char str2[10] = "<89>PNG";

		if ( !(strncmp(buffer, str1, 4)) || !(strncmp(buffer, str2, 6)) )
		{
			m_grtype = GRT_Raster;
			if(m_surface) {
				cairo_surface_destroy(m_surface);
			}
			
			_PNG_read_state closure(pBB);
			m_surface = cairo_image_surface_create_from_png_stream (&_UT_ByteBuf_PNG_read, &closure);
		}
	} else {
		m_grtype = GRT_Vector;
	}

	return true;
}
Exemplo n.º 26
0
/**
 * Push a new layer with multiple definitions creating the appropriate closures
 * @param ldefs list of pairs (symbol id x definition) to be binded to the symbol id
 * @param visited set of visited symbols (used for recursive definition detection)
 * @param lenv the environment where to push the layer and add all the definitions
 * @return the new environment
 */
Tree pushMultiClosureDefs(Tree ldefs, Tree visited, Tree lenv)
{
  Tree lenv2 = pushNewLayer(lenv);

  while(!isNil(ldefs))
  {
    Tree def = hd(ldefs);
    Tree id = hd(def);
    Tree rhs = tl(def);
    Tree cl = closure(tl(def), nil, visited, lenv2);
    stringstream s;
    s << boxpp(id);

    if(!isBoxCase(rhs))
      setDefNameProperty(cl, s.str());

    addLayerDef(id, cl, lenv2);
    ldefs = tl(ldefs);
  }

  return lenv2;
}
Exemplo n.º 27
0
jvmtiError
JvmtiGetLoadedClasses::getClassLoaderClasses(JvmtiEnv *env, jobject initiatingLoader,
                                             jint* classCountPtr, jclass** classesPtr) {
  // Since SystemDictionary::classes_do only takes a function pointer
  // and doesn't call back with a closure data pointer,
  // we can only pass static methods.
  JvmtiGetLoadedClassesClosure closure(initiatingLoader);
  {
    // To get a consistent list of classes we need MultiArray_lock to ensure
    // array classes aren't created, and SystemDictionary_lock to ensure that
    // classes aren't added to the system dictionary,
    MutexLocker ma(MultiArray_lock);
    MutexLocker sd(SystemDictionary_lock);
    // First, count the classes in the system dictionary which have this loader recorded
    // as an initiating loader. For basic type arrays this information is not recorded
    // so GetClassLoaderClasses will return all of the basic type arrays. This is okay
    // because the defining loader for basic type arrays is always the boot class loader
    // and these classes are "visible" to all loaders.
    SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::increment_with_loader);
    Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::increment_for_basic_type_arrays);
    // Next, fill in the classes
    closure.allocate();
    SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::add_with_loader);
    Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::add_for_basic_type_arrays);
    // Drop the SystemDictionary_lock, so the results could be wrong from here,
    // but we still have a snapshot.
  }
  // Post results
  jclass* result_list;
  jvmtiError err = env->Allocate(closure.get_count() * sizeof(jclass),
                                 (unsigned char**)&result_list);
  if (err != JVMTI_ERROR_NONE) {
    return err;
  }
  closure.extract(env, result_list);
  *classCountPtr = closure.get_count();
  *classesPtr = result_list;
  return JVMTI_ERROR_NONE;
}
Exemplo n.º 28
0
int main()
{
	int nfa[20][20],i,j,n,k,tk,t;
	
	printf("\nEnter the no. of states : ");
	scanf("%d",&n);
	n--;
	printf("\nEnter the transition table\n");
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			scanf("%d",&nfa[i][j]);
		}
	printf("\n");
	}

	printf("\nThe Transition Table :\n");
	for(i=0;i<=n;i++)
	{
		printf("\n");
		for(j=0;j<=n;j++)
		{
			printf("%d\t",nfa[i][j]);
		}	
	}
/*
	printf("\nE-Closure \nEnter the state : \t");
	scanf("%d",&k);
	printf("\nE-Closure of %d :\n",k);
	k--;
*/
	for(i=0;i<=n;i++)
	{	
		printf("\n\nE-Closure of %d :\n",i+1);
		closure(nfa,i,n);
	}
}
Exemplo n.º 29
0
Expr* PrimInliner::primitiveFailure(symbolOop failureCode) {
  // compile a failing primitive
  if (CompilerDebug) cout(PrintInlining)->print("%*sprimitive %s will fail: %s\n", _scope->depth + 2, "", _pdesc->name(), failureCode->as_string());
  if (_failure_block == NULL) {
    error("\nPotential compiler bug: compiler believes primitive %s will fail\nwith error %s, but primitive has no failure block.\n",
          _pdesc->name(), failureCode->as_string());
    return NULL;
  }
  // The byte code compiler stores the primitive result in a temporary (= the parameter of
  // the inlined failure block).  Thus, we store res in the corresponding temp Expr so that
  // its value isn't forgotten (the default Expr for temps is UnknownExpr) and restore the
  // temp's original value afterwards. This is safe because within the failure block that
  // temporary is treated as a parameter and therefore is read-only.
  AssignmentFinder closure(_failure_block);
  assert(closure.interval != NULL, "no assignment found");
  Expr* old_temp = _scope->temporary(closure.tempNo);	// save temp
  Expr* res = new ConstantExpr(failureCode, new_ConstPReg(_scope, failureCode), _gen->current());
  _scope->set_temporary(closure.tempNo, res);
  closure.set_prim_failure(false);		// allow inlining sends in failure branch
  _gen->generate_subinterval(closure.interval, true);
  _scope->set_temporary(closure.tempNo, old_temp);
  return _gen->exprStack()->pop();		// restore temp
}
Exemplo n.º 30
0
bool TypeHierarchy::reachable(const TypeRef & t1,const TypeRef & t2)
{
	if(t1 == t2) return true;

	Graph::iterator i = graph.find(&t1);
	if(i == graph.end()) 
	{
		return false;
	};
	
	Graph::const_iterator j = graph.find(&t2);
	if(j == graph.end() && t2.expected()) 
	{
		return false;
	};
	t2.addContents(this);
	j = graph.find(&t2);
	
	if(i->second.find(j->first) != i->second.end()) return true;

	Nodes ns;
	return closure(graph,i,ns,i,j->first);
};