void weak_shared(
    boost::weak_ptr<FIRST>& first, 
    boost::shared_ptr<SECOND>& second
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);
    int firstm = first.lock()->m_x;
    int secondm = second->m_x;
    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();

    load2(testfile, first, second);

    // Check data member
    BOOST_CHECK(firstm == first.lock()->m_x);
    BOOST_CHECK(secondm == second->m_x);
    // Check pointer to vtable
    BOOST_CHECK(boost::dynamic_pointer_cast<Sub>(first.lock()));
    BOOST_CHECK(boost::dynamic_pointer_cast<Sub>(second));

    std::remove(testfile);
}
void shared_weak(
    SP & first,
    WP & second
){
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);
    int firstm = first->m_x;
    
    BOOST_REQUIRE(! second.expired());
    int secondm = second.lock()->m_x;
    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    second.reset();
    first.reset();

    load2(testfile, first, second);
    BOOST_CHECK(! second.expired());

    // Check data member
    BOOST_CHECK(firstm == first->m_x);
    BOOST_CHECK(secondm == second.lock()->m_x);
    // Check pointer to vtable
    BOOST_CHECK(::dynamic_pointer_cast<Sub>(first));
    BOOST_CHECK(::dynamic_pointer_cast<Sub>(second.lock()));

    std::remove(testfile);
}
Beispiel #3
0
static void execSave(Inst inst)
{
    RegisterExp regExp = insGetSave(inst);
    char* name = rexGetName(regExp);
    Register reg = rexGetReg(regExp);
#ifdef STACK_GUARDED
    save2(name, reg);
#else
    save(reg);
#endif
    rsAdvancePc();
}
Beispiel #4
0
int main()
{
	int num;
	int count = 0;

	TMOD=0x01;
	TH0=(65536-50000)/256;
	TL0=(65536-50000)%256;
	EA=1;
	ET0=1;    //开中断
	TR0=1;
		
	init();
	P2=0xff;
st:	lock=0;
	while(1)
	{	
		write_com(0x01);
		write_lcd(0x40,"save        take");
		num = key();
		if(num == 10)	//存放模式
		{
			NO1 = TH0;
			NO2 = TL0;
			save2();
		}
		if(num == 11) //取出模式
		{
			take2();
		}
	 if(lock>4)
	 {	 
	 lk:	write_com(0x01);
	 	write_lcd(0x00,"    lock on!    ");
		while(1)
		{
			if(key() == 13)
			{
				write_lcd(0x00,"admin:          ");
				if(admin_key() == 1)
				{
					lock = 0;
					 goto st;
				}
				goto lk;
			}
		}
	 }
	}
 	return 0;

}
void to_hex(std::ostream& out, BinarySequence::const_iterator begin, BinarySequence::const_iterator end) {
    boost::io::ios_flags_saver save1(out);
    boost::io::ios_width_saver save2(out);
    boost::io::ios_precision_saver save3(out);
    out << std::hex << std::setw(1) << std::setprecision(1);
    while(end - begin >= 4) {
        int x = 0;
        for(int i=0; i<4; ++i) {
            x |= begin.pop<bool>() << i;
        }
        out << x;
    }
}
// Run tests by serializing two shared_ptrs into an archive,
// clearing them (deleting the objects) and then reloading the
// objects back from an archive.
void save_and_load2(boost::shared_ptr<A>& first, boost::shared_ptr<A>& second)
{
    const char * testfile = boost::archive::tmpnam(NULL);
    BOOST_REQUIRE(NULL != testfile);

    save2(testfile, first, second);

    // Clear the pointers, thereby destroying the objects they contain
    first.reset();
    second.reset();

    load2(testfile, first, second);

    BOOST_CHECK(first == second);
    std::remove(testfile);
}
Beispiel #7
0
/*==================================
	ParseColorPattern
===================================*/
void PTPatternView::ParseColorPattern( Handle inPattern, SUOffscreen **outColor,
												SUOffscreen **outBW )
{
	// See IM V-79 for details

	StSaveGWorld		save1;
	StHandleLocker		save2( inPattern );
	PixPatPtr			p = (PixPatPtr) *inPattern;
	CTabHandle			theTable = nil;
	SUOffscreen			*tempColorBuffer = nil, *colorBuffer = nil, *bwBuffer = nil;

	try
	{	
		if ( p->patType != 1 )
			LException::Throw( err_InvalidImageFormat );
			
		/*******************************************
			first handle the b&w pattern
		********************************************/
		bwBuffer = this->BWPatternToOffscreen( p->pat1Data );

		/*******************************************
			now the color pattern
		********************************************/
		PixMapPtr			theMap = (PixMapPtr)( *inPattern + (SInt32) p->patMap );
		UInt8 *				theData = (UInt8*)( *inPattern + (SInt32) p->patData );
		
		SInt32				depth = theMap->pixelSize;
		SInt32				width = theMap->bounds.right - theMap->bounds.left;
		SInt32				height = theMap->bounds.bottom - theMap->bounds.top;
		SInt32				rowBytes = theMap->rowBytes & 0x3FFF;		// clear flags
		
		if ( (depth != 1) && (depth != 2) && (depth != 4) && (depth != 8) )
			LException::Throw( err_InvalidImageDepth );
		
		if ( (width <= 3) || (width > 64) || (height <= 3) || (height > 64) )
			LException::Throw( err_InvalidImageSize );
		
		theTable = SUColorUtils::NewColorTableFromPtr( depth, (UInt8*)( *inPattern + (SInt32)theMap->pmTable) );
		tempColorBuffer = SUOffscreen::CreateBuffer( width, height, depth, theTable );
		tempColorBuffer->CopyFromRawData( theData, rowBytes );

		// now switch to a 32-bit buffer
		colorBuffer = SUOffscreen::CreateBuffer( width, height, 32 );
		colorBuffer->CopyFrom( tempColorBuffer );
	}
	catch( ... )
	{
		delete colorBuffer;
		delete bwBuffer;
		delete tempColorBuffer;
		if ( theTable )
			::DisposeCTable( theTable );
		throw;
	}
	
	*outColor = colorBuffer;
	*outBW = bwBuffer;

	if ( theTable )
		::DisposeCTable( theTable );
	delete tempColorBuffer;
}
/* An explicit control evaluator, taken almost directly from SICP, section
 * 5.2.  list is a flat list of expressions to evaluate.  where is a label to
 * begin at.  Return value depends on where.
 */ 
NODE *evaluator(NODE *list, enum labels where) {

    /* registers */
    NODE    *exp    = NIL,  /* the current expression */
	    *val    = NIL,  /* the value of the last expression */
	    *proc   = NIL,  /* the procedure definition */
	    *argl   = NIL,  /* evaluated argument list */
	    *unev   = NIL,  /* list of unevaluated expressions */
	    *stack  = NIL,  /* register stack */
	    *parm   = NIL,  /* the current formal */
	    *catch_tag = NIL,
	    *arg    = NIL;  /* the current actual */

/* registers that don't get reference counted, so we pretend they're ints */
FIXNUM	    vsp    = 0,		/* temp ptr into var_stack */
	    cont   = 0,		/* where to go next */
	    formals = (FIXNUM)NIL; /* list of formal parameters */

    int i, nargs;
    BOOLEAN tracing;	    /* are we tracing the current procedure? */
    FIXNUM oldtailcall;	    /* in case of reentrant use of evaluator */
    FIXNUM repcount;	    /* count for repeat */
    FIXNUM old_ift_iff;

    oldtailcall = tailcall;
    old_ift_iff = ift_iff_flag;
    save2(var,this_line);
    assign(var, var_stack);
    save2(fun,ufun);
    cont = (FIXNUM)all_done;
    numsave((FIXNUM)cont);
    newcont(where);
    goto fetch_cont;
    
begin_line:
    ref(list);
    assign(this_line, list);
    newcont(end_line);
begin_seq:
    make_tree(list);
    if (!is_tree(list)) {
	assign(val, UNBOUND);
	goto fetch_cont;
    }
    assign(unev, tree__tree(list));
    assign(val, UNBOUND);
    goto eval_sequence;

end_line:
    if (val != UNBOUND) {
	if (NOT_THROWING) err_logo(DK_WHAT, val);
	deref(val);
    }
    val = NIL;
    deref(list);
    goto fetch_cont;


/* ----------------- EVAL ---------------------------------- */

tail_eval_dispatch:
    tailcall = 1;
eval_dispatch:
    switch (nodetype(exp)) {
	case QUOTE:			/* quoted literal */
	    assign(val, node__quote(exp));
	    goto fetch_cont;
	case COLON:			/* variable */
	    assign(val, valnode__colon(exp));
	    while (val == UNBOUND && NOT_THROWING)
		assign(val, err_logo(NO_VALUE, node__colon(exp)));
	    goto fetch_cont;
	case CONS:			/* procedure application */
	    if (tailcall == 1 && is_macro(car(exp)) &&
				 is_list(procnode__caseobj(car(exp)))) {
		/* tail call to user-defined macro must be treated as non-tail
		 * because the expression returned by the macro
		 * remains to be evaluated in the caller's context */
		assign(unev, NIL);
		goto non_tail_eval;
	    }
	    assign(fun, car(exp));
	    if (cdr(exp) != NIL)
		goto ev_application;
	    else
		goto ev_no_args;
	default:
	    assign(val, exp);		/* self-evaluating */
	    goto fetch_cont;
    }

ev_no_args:
    /* Evaluate an application of a procedure with no arguments. */
    assign(argl, NIL);
    goto apply_dispatch;    /* apply the procedure */

ev_application:
    /* Evaluate an application of a procedure with arguments. */
    assign(unev, cdr(exp));
    assign(argl, NIL);
    mixsave(tailcall,var);
    num2save(val_status,ift_iff_flag);
    save2(didnt_get_output,didnt_output_name);
eval_arg_loop:
    if (unev == NIL) goto eval_args_done;
    assign(exp, car(unev));
    if (exp == Not_Enough_Node) {
	if (NOT_THROWING)
	    err_logo(NOT_ENOUGH, NIL);
	goto eval_args_done;
    }
    save(argl);
    save2(unev,fun);
    save2(ufun,last_ufun);
    save2(this_line,last_line);
    assign(var, var_stack);
    tailcall = -1;
    val_status = 1;
    assign(didnt_get_output,
	   cons_list(0,fun,ufun,this_line,END_OF_LIST));
    assign(didnt_output_name, NIL);
    newcont(accumulate_arg);
    goto eval_dispatch;	    /* evaluate the current argument */

accumulate_arg:
    /* Put the evaluated argument into the argl list. */
    reset_args(var);
    restore2(this_line,last_line);
    restore2(ufun,last_ufun);
    assign(last_call, fun);
    restore2(unev,fun);
    restore(argl);
    while (NOT_THROWING && val == UNBOUND) {
	assign(val, err_logo(DIDNT_OUTPUT, NIL));
    }
    push(val, argl);
    pop(unev);
    goto eval_arg_loop;

eval_args_done:
    restore2(didnt_get_output,didnt_output_name);
    num2restore(val_status,ift_iff_flag);
    mixrestore(tailcall,var);
    if (stopping_flag == THROWING) {
	assign(val, UNBOUND);
	goto fetch_cont;
    }
    assign(argl, reverse(argl));
/* --------------------- APPLY ---------------------------- */
apply_dispatch:
    /* Load in the procedure's definition and decide whether it's a compound
     * procedure or a primitive procedure.
     */
    proc = procnode__caseobj(fun);
    if (is_macro(fun)) {
	num2save(val_status,tailcall);
	val_status = 1;
	newcont(macro_return);
    }
    if (proc == UNDEFINED) {
	if (ufun != NIL) {
	    untreeify_proc(ufun);
	}
	if (NOT_THROWING)
	    assign(val, err_logo(DK_HOW, fun));
	else
	    assign(val, UNBOUND);
	goto fetch_cont;
    }
    if (is_list(proc)) goto compound_apply;
    /* primitive_apply */
    if (NOT_THROWING)
	assign(val, (*getprimfun(proc))(argl));
    else
	assign(val, UNBOUND);
#define do_case(x) case x: goto x;
fetch_cont:
    {
	enum labels x = (enum labels)cont;
	cont = (FIXNUM)car(stack);
	numpop(&stack);
	switch (x) {
	    do_list(do_case)
	    default: abort();
	}
    }

compound_apply:
#ifdef mac
    check_mac_stop();
#endif
#ifdef ibm
    check_ibm_stop();
#endif
    if (tracing = flag__caseobj(fun, PROC_TRACED)) {
	for (i = 0; i < trace_level; i++) print_space(writestream);
	trace_level++;
	ndprintf(writestream, "( %s ", fun);
    }
/* Bind the actuals to the formals */
    vsp = (FIXNUM)var_stack;	/* remember where we came in */
    for (formals = (FIXNUM)formals__procnode(proc);
    	 formals != (FIXNUM)NIL;
	 formals = (FIXNUM)cdr((NODE *)formals)) {
	    parm = car((NODE *)formals);
	    if (nodetype(parm) == INT) break;	/* default # args */
	    if (argl != NIL) {
		arg = car(argl);
		if (tracing) {
		    print_node(writestream, maybe_quote(arg));
		    print_space(writestream);
		}
	    } else
		arg = UNBOUND;
	    if (nodetype(parm) == CASEOBJ) {
		if (not_local(parm,(NODE *)vsp)) {
		    push(parm, var_stack);
		    setobject(var_stack, valnode__caseobj(parm));
		}
		tell_shadow(parm);
		setvalnode__caseobj(parm, arg);
	    } else if (nodetype(parm) == CONS) {
		/* parm is optional or rest */
		if (not_local(car(parm),(NODE *)vsp)) {
		    push(car(parm), var_stack);
		    setobject(var_stack, valnode__caseobj(car(parm)));
		}
		tell_shadow(car(parm));
		if (cdr(parm) == NIL) {		    /* parm is rest */
		    setvalnode__caseobj(car(parm), argl);
		    break;
		}
		if (arg == UNBOUND) {		    /* use default */
		    save2(fun,var);
		    save2(ufun,last_ufun);
		    save2(this_line,last_line);
		    save2(didnt_output_name,didnt_get_output);
		    num2save(ift_iff_flag,val_status);
		    assign(var, var_stack);
		    tailcall = -1;
		    val_status = 1;
		    mixsave(formals,argl);
		    numsave(vsp);
		    assign(list, cdr(parm));
		    if (NOT_THROWING)
			make_tree(list);
		    else
			assign(list, NIL);
		    if (!is_tree(list)) {
			assign(val, UNBOUND);
			goto set_args_continue;
		    }
		    assign(unev, tree__tree(list));
		    assign(val, UNBOUND);
		    newcont(set_args_continue);
		    goto eval_sequence;

set_args_continue:
		    numrestore(vsp);
		    mixrestore(formals,argl);
		    parm = car((NODE *)formals);
		    reset_args(var);
		    num2restore(ift_iff_flag,val_status);
		    restore2(didnt_output_name,didnt_get_output);
		    restore2(this_line,last_line);
		    restore2(ufun,last_ufun);
		    restore2(fun,var);
		    arg = val;
		}
		setvalnode__caseobj(car(parm), arg);
	    }
	    if (argl != NIL) pop(argl);
    }
    if (check_throwing) {
	assign(val, UNBOUND);
	goto fetch_cont;
    }
    vsp = 0;
    if (tracing = flag__caseobj(fun, PROC_TRACED)) {
	if (NOT_THROWING) print_char(writestream, ')');
	new_line(writestream);
	save(fun);
	newcont(compound_apply_continue);
    }
    assign(val, UNBOUND);
    assign(last_ufun, ufun);
    assign(ufun, fun);
    assign(last_line, this_line);
    assign(this_line, NIL);
    proc = procnode__caseobj(fun);
    assign(list, bodylist__procnode(proc));	/* get the body ... */
    make_tree_from_body(list);
    if (!is_tree(list)) {
	goto fetch_cont;
    }
    assign(unev, tree__tree(list));
    if (NOT_THROWING) stopping_flag = RUN;
    assign(output_node, UNBOUND);
    if (val_status == 1) val_status = 2;
    else if (val_status == 5) val_status = 3;
    else val_status = 0;
eval_sequence:
    /* Evaluate each expression in the sequence.  Stop as soon as
     * val != UNBOUND.
     */
    if (!RUNNING || val != UNBOUND) {
	goto fetch_cont;
    }
    if (nodetype(unev) == LINE) {
	assign(this_line, unparsed__line(unev));
	if (flag__caseobj(ufun, PROC_STEPPED)) {
	    char junk[20];

	    if (tracing) {
		int i = 1;
		while (i++ < trace_level) print_space(stdout);
	    }
	    print_node(stdout, this_line);
	    ndprintf(stdout, " >>> ");
	    input_blocking++;
#ifndef TIOCSTI
	    if (!setjmp(iblk_buf))
#endif
#ifdef __ZTC__
		ztc_getcr();
#else
		fgets(junk, 19, stdin);
#endif
	    input_blocking = 0;
	    update_coords('\n');
	}
    }
    assign(exp, car(unev));
    pop(unev);
    if (is_list(exp) && (is_tailform(procnode__caseobj(car(exp))))) {
      if (nameis(car(exp),Output) || nameis(car(exp),Op)) {
	assign(didnt_get_output,
	       cons_list(0,car(exp),ufun,this_line,END_OF_LIST));
	assign(didnt_output_name, NIL);
	if (val_status == 2 || val_status == 3) {
	    val_status = 1;
	    assign(exp, cadr(exp));
	    goto tail_eval_dispatch;
	} else if (ufun == NIL) {
	    err_logo(AT_TOPLEVEL,car(exp));
	    assign(val, UNBOUND);
	    goto fetch_cont;
	} else if (val_status < 4) {
	    val_status = 1;
	    assign(exp, cadr(exp));
	    assign(unev, NIL);
	    goto non_tail_eval;	    /* compute value then give error */
	}
      } else if (nameis(car(exp),Stop)) {
	if (ufun == NIL) {
	    err_logo(AT_TOPLEVEL,car(exp));
	    assign(val, UNBOUND);
	    goto fetch_cont;
	} else if (val_status == 0 || val_status == 3) {
	    assign(val, UNBOUND);
	    goto fetch_cont;
	} else if (val_status < 4) {
	    assign(didnt_output_name, fun);
	    assign(val, UNBOUND);
	    goto fetch_cont;
	}
      } else { /* maybeoutput */
	assign(exp, cadr(exp));
	val_status = 5;
	goto tail_eval_dispatch;
      }
    }
    if (unev == NIL) {
	if (val_status == 2 || val_status == 4) {
	    assign(didnt_output_name, fun);
	    assign(unev, UNBOUND);
	    goto non_tail_eval;
	} else {
	    goto tail_eval_dispatch;
	}
    }
    if (is_list(car(unev)) && nameis(car(car(unev)),Stop)) {
	if ((val_status == 0 || val_status == 3) && ufun != NIL) {
	    goto tail_eval_dispatch;
	} else if (val_status < 4) {
	    assign(didnt_output_name, fun);
	    goto tail_eval_dispatch;
	}
    }
non_tail_eval:
    save2(unev,fun);
    num2save(ift_iff_flag,val_status);
    save2(ufun,last_ufun);
    save2(this_line,last_line);
    save(var);
    assign(var, var_stack);
    tailcall = 0;
    newcont(eval_sequence_continue);
    goto eval_dispatch;

eval_sequence_continue:
    reset_args(var);
    restore(var);
    restore2(this_line,last_line);
    restore2(ufun,last_ufun);
    if (dont_fix_ift) {
	num2restore(dont_fix_ift,val_status);
	dont_fix_ift = 0;
    } else
	num2restore(ift_iff_flag,val_status);
    restore2(unev,fun);
    if (stopping_flag == MACRO_RETURN) {
	if (unev == UNBOUND) assign(unev, NIL);
	assign(unev, append(val, unev));
	assign(val, UNBOUND);
	stopping_flag = RUN;
	if (unev == NIL) goto fetch_cont;
    } else if (val_status < 4) {
	if (STOPPING || RUNNING) assign(output_node, UNBOUND);
	if (stopping_flag == OUTPUT || STOPPING) {
	    stopping_flag = RUN;
	    assign(val, output_node);
	    if (val != UNBOUND && val_status < 2 && NOT_THROWING) {
		assign(didnt_output_name,Output);
		err_logo(DIDNT_OUTPUT,Output);
	    }
	    if (val == UNBOUND && val_status == 1 && NOT_THROWING) {
		assign(didnt_output_name,Stop);
		err_logo(DIDNT_OUTPUT,Output);
	    }
	    goto fetch_cont;
	}
    }
    if (val != UNBOUND) {
	err_logo((unev == NIL ? DK_WHAT_UP : DK_WHAT), val);
	assign(val, UNBOUND);
    }
    if (NOT_THROWING && (unev == NIL || unev == UNBOUND)) {
	if (val_status != 4)  err_logo(DIDNT_OUTPUT,NIL);
	goto fetch_cont;
    }
    goto eval_sequence;

compound_apply_continue:
    /* Only get here if tracing */
    restore(fun);
    --trace_level;
    if (NOT_THROWING) {
	for (i = 0; i < trace_level; i++) print_space(writestream);
	print_node(writestream, fun);
	if (val == UNBOUND)
	    ndprintf(writestream, " stops\n");
	else {
	    ref(val);
	    ndprintf(writestream, " outputs %s\n", maybe_quote(val));
	    deref(val);
	}
    }
    goto fetch_cont;

/* --------------------- MACROS ---------------------------- */

macro_return:
    num2restore(val_status,tailcall);
    while (!is_list(val) && NOT_THROWING) {
	assign(val,err_logo(ERR_MACRO,val));
    }
    if (NOT_THROWING) {
	if (is_cont(val)) {
	    newcont(cont__cont(val));
	    val->n_car = NIL;
	    assign(val, val__cont(val));
	    goto fetch_cont;
	}
macro_reval:
	if (tailcall == 0) {
	    make_tree(val);
	    stopping_flag = MACRO_RETURN;
	    if (!is_tree(val)) assign(val, NIL);
	    else assign(val, tree__tree(val));
	    goto fetch_cont;
	}
	assign(list,val);
	goto begin_seq;
    }
    assign(val, UNBOUND);
    goto fetch_cont;

runresult_continuation:
    assign(list, val);
    newcont(runresult_followup);
    val_status = 5;
    goto begin_seq;

runresult_followup:
    if (val == UNBOUND) {
	assign(val, NIL);
    } else {
	assign(val, cons(val, NIL));
    }
    goto fetch_cont;

repeat_continuation:
    assign(list, cdr(val));
    repcount = getint(car(val));
repeat_again:
    assign(val, UNBOUND);
    if (repcount == 0) goto fetch_cont;
    mixsave(repcount,list);
    num2save(val_status,tailcall);
    val_status = 4;
    newcont(repeat_followup);
    goto begin_seq;

repeat_followup:
    if (val != UNBOUND && NOT_THROWING) {
	ref(val);
	err_logo(DK_WHAT, val);
	unref(val);
    }
    num2restore(val_status,tailcall);
    mixrestore(repcount,list);
    if (val_status < 4 && tailcall != 0) {
	if (STOPPING || RUNNING) assign(output_node, UNBOUND);
	if (stopping_flag == OUTPUT || STOPPING) {
	    stopping_flag = RUN;
	    assign(val, output_node);
	    if (val != UNBOUND && val_status < 2) {
		err_logo(DK_WHAT_UP,val);
	    }
	    goto fetch_cont;
	}
    }
    if (repcount > 0)    /* negative means forever */
	--repcount;
#ifdef mac
    check_mac_stop();
#endif
#ifdef ibm
    check_ibm_stop();
#endif
    if (RUNNING) goto repeat_again;
    assign(val, UNBOUND);
    goto fetch_cont;

catch_continuation:
    assign(list, cdr(val));
    assign(catch_tag, car(val));
    if (compare_node(catch_tag,Error,TRUE) == 0) {
	push(Erract, var_stack);
	setobject(var_stack, valnode__caseobj(Erract));
	setvalnode__caseobj(Erract, UNBOUND);
    }
    save(catch_tag);
    save2(didnt_output_name,didnt_get_output);
    num2save(val_status,tailcall);
    newcont(catch_followup);
    val_status = 5;
    goto begin_seq;

catch_followup:
    num2restore(val_status,tailcall);
    restore2(didnt_output_name,didnt_get_output);
    restore(catch_tag);
    if (val_status < 4 && tailcall != 0) {
	if (STOPPING || RUNNING) assign(output_node, UNBOUND);
	if (stopping_flag == OUTPUT || STOPPING) {
	    stopping_flag = RUN;
	    assign(val, output_node);
	    if (val != UNBOUND && val_status < 2) {
		err_logo(DK_WHAT_UP,val);
	    }
	}
    }
    if (stopping_flag == THROWING &&
	compare_node(throw_node, catch_tag, TRUE) == 0) {
	    throw_node = reref(throw_node, UNBOUND);
	    stopping_flag = RUN;
	    assign(val, output_node);
    }
    goto fetch_cont;

begin_apply:
    /* This is for lapply. */
    assign(fun, car(val));
    while (nodetype(fun) == ARRAY && NOT_THROWING)
	assign(fun, err_logo(APPLY_BAD_DATA, fun));
    assign(argl, cadr(val));
    assign(val, UNBOUND);
    while (!is_list(argl) && NOT_THROWING)
	assign(argl, err_logo(APPLY_BAD_DATA, argl));
    if (NOT_THROWING && fun != NIL) {
	if (is_list(fun)) {		    /* template */
	    if (is_list(car(fun)) && cdr(fun) != NIL) {
		/* lambda form */
		formals = (FIXNUM)car(fun);
		numsave(tailcall);
		tailcall = 0;
		llocal((NODE *)formals);    /* bind the formals locally */
		numrestore(tailcall);
		for ( ;
		     formals && argl && NOT_THROWING;
		     formals = (FIXNUM)cdr((NODE *)formals),
		     assign(argl, cdr(argl)))
			setvalnode__caseobj(car((NODE *)formals), car(argl));
		assign(val, cdr(fun));
		goto macro_reval;
	    } else {		/* question-mark form */
		save(qm_list);
		assign(qm_list, argl);
		assign(list, fun);
		make_tree(list);
		if (list == NIL || !is_tree(list)) {
		    goto qm_failed;
		}
		assign(unev, tree__tree(list));
		save2(didnt_output_name,didnt_get_output);
		num2save(val_status,tailcall);
		newcont(qm_continue);
		val_status = 5;
		goto eval_sequence;

qm_continue:
		num2restore(val_status,tailcall);
		restore2(didnt_output_name,didnt_get_output);
		if (val_status < 4 && tailcall != 0) {
		    if (STOPPING || RUNNING) assign(output_node, UNBOUND);
		    if (stopping_flag == OUTPUT || STOPPING) {
			stopping_flag = RUN;
			assign(val, output_node);
			if (val != UNBOUND && val_status < 2) {
			    err_logo(DK_WHAT_UP,val);
			}
		    }
		}
qm_failed:
		restore(qm_list);
		goto fetch_cont;
	    }
	} else {    /* name of procedure to apply */
	    int min, max, n;
	    NODE *arg;
	    assign(fun, intern(fun));
	    if (procnode__caseobj(fun) == UNDEFINED && NOT_THROWING &&
		fun != Null_Word)
		    silent_load(fun, NULL);    /* try ./<fun>.lg */
	    if (procnode__caseobj(fun) == UNDEFINED && NOT_THROWING &&
		fun != Null_Word)
		    silent_load(fun, logolib); /* try <logolib>/<fun> */
	    proc = procnode__caseobj(fun);
	    while (proc == UNDEFINED && NOT_THROWING) {
		assign(val, err_logo(DK_HOW_UNREC, fun));
	    }
	    if (NOT_THROWING) {
		if (nodetype(proc) == CONS) {
		    min = getint(minargs__procnode(proc));
		    max = getint(maxargs__procnode(proc));
		} else {
		    if (getprimdflt(proc) < 0) {	    /* special form */
			err_logo(DK_HOW_UNREC, fun);    /* can't apply */
			goto fetch_cont;
		    } else {
			min = getprimmin(proc);
			max = getprimmax(proc);
		    }
		}
		for (n = 0, arg = argl; arg != NIL; n++, arg = cdr(arg));
		if (n < min) {
		    err_logo(NOT_ENOUGH, NIL);
		} else if (n > max && max >= 0) {
		    err_logo(TOO_MUCH, NIL);
		} else {
		    goto apply_dispatch;
		}
	    }
	}
    }
    goto fetch_cont;

all_done:
    tailcall = oldtailcall;
    ift_iff_flag = old_ift_iff;
    restore2(fun,ufun);
    reset_args(var);
    restore2(var,this_line);
    deref(argl);deref(unev);deref(stack);deref(catch_tag);deref(exp);
    return(val);
}
Beispiel #9
0
void Keys::save(void)
{
    data->crc8    = crc8( (uint8_t*)data, sizeof(KeysCRCed), CRC8INIT );
    eeprom_write_block((const void*)data,   (void*)EEPROM_KEYS_OFFSET,        sizeof(KeysShared));
    save2();
}
Beispiel #10
0
void shakil::first()
{
   tm=0;
   showmouseptr();


 while(1)
{
 getmousepos(&button,&x,&y);
 if(tm==0)
 {
   hidemouseptr();
   setcolor(7);
   rectangle(105,105,345,155);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,110,7);
   rectangle(105,160,345,205);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,170,7);
   rectangle(105,210,345,255);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,220,7);
   rectangle(105,260,345,305);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,270,7);
   rectangle(105,310,345,345);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,320,7);
   setcolor(RED);
   settextstyle(1,0,5);
   outtextxy(130,106," NEW ");
   outtextxy(130,161," EASY ");
   outtextxy(130,211," EXIT ");
   outtextxy(95,255," LOAD GAME");
   outtextxy(105,300,"TURNAMENT");
   rectangle(100,100,350,350);
   tm=10;
   showmouseptr();
   }
   p=x;m=y;

 if(p>105&&p<345)
 {if((m>105&&m<155)&&tm!=1)
  {tm=1;
   hidemouseptr();
   setcolor(123);
   rectangle(105,105,345,155);
   setfillstyle(SOLID_FILL,123);
   floodfill(110,110,123);
   setcolor(7);
   rectangle(105,160,345,205);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,170,7);
   rectangle(105,210,345,255);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,220,7);
   rectangle(105,260,345,305);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,270,7);
   rectangle(105,310,345,345);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,320,7);
   setcolor(RED);
   settextstyle(1,0,5);
   outtextxy(130,106," NEW ");
   outtextxy(130,161," EASY ");
   outtextxy(130,211," EXIT ");
   outtextxy(95,255," LOAD GAME");
   outtextxy(105,300,"TURNAMENT");
   rectangle(100,100,350,350);
   showmouseptr();
  }
  if((m>160&&m<205)&&tm!=2)
  { tm=2;
    hidemouseptr();
    setcolor(123);
    rectangle(105,160,345,205);
    setfillstyle(SOLID_FILL,123);
    floodfill(110,170,123);
    setcolor(7);
    rectangle(105,105,345,155);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,110,7);
    rectangle(105,210,345,255);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,220,7);
    rectangle(105,260,345,305);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,270,7);
    rectangle(105,310,345,345);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,320,7);
    setcolor(RED);
    settextstyle(1,0,5);
    outtextxy(130,106," NEW ");
    outtextxy(130,161," EASY ");
    outtextxy(130,211," EXIT ");
    outtextxy(95,255," LOAD GAME");
    outtextxy(105,300,"TURNAMENT");
    rectangle(100,100,350,350);
    showmouseptr();
  }
   if((m>210&&m<255)&&tm!=3)
  { tm=3;
    hidemouseptr();
    setcolor(123);
    rectangle(105,210,345,255);
    setfillstyle(SOLID_FILL,123);
    floodfill(110,220,123);
    setcolor(7);
    rectangle(105,160,345,205);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,170,7);
    rectangle(105,105,345,155);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,110,7);
    rectangle(105,260,345,305);
    setfillstyle(SOLID_FILL,7);
    floodfill(110,270,7);
    rectangle(105,310,345,345);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,320,7);
    setcolor(RED);
    settextstyle(1,0,5);
    outtextxy(130,106," NEW ");
    outtextxy(130,161," EASY ");
    outtextxy(130,211," EXIT ");
    outtextxy(95,255," LOAD GAME");
    outtextxy(105,300,"TURNAMENT");
    rectangle(100,100,350,350);
    showmouseptr();
   }
   if((m>260&&m<305)&&tm!=4)
  {tm=4;
   hidemouseptr();
   setcolor(123);
   rectangle(105,260,345,305);
   setfillstyle(SOLID_FILL,123);
   floodfill(110,270,123);
   setcolor(7);
   rectangle(105,160,345,205);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,170,7);
   rectangle(105,210,345,255);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,220,7);
   rectangle(105,105,345,155);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,110,7);
   rectangle(105,310,345,345);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,320,7);
   setcolor(RED);
   settextstyle(1,0,5);
   outtextxy(130,106," NEW ");
   outtextxy(130,161," EASY ");
   outtextxy(130,211," EXIT ");
   outtextxy(95,255," LOAD GAME");
   outtextxy(105,300,"TURNAMENT");
   rectangle(100,100,350,350);
   showmouseptr();
  }
   if((m>310&&m<345)&&tm!=5)
  {tm=5;
   hidemouseptr();
   setcolor(123);
   rectangle(105,310,345,345);
   setfillstyle(SOLID_FILL,123);
   floodfill(110,320,123);
   setcolor(7);
   rectangle(105,160,345,205);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,170,7);
   rectangle(105,210,345,255);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,220,7);
   rectangle(105,105,345,155);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,110,7);

   rectangle(105,260,345,305);
   setfillstyle(SOLID_FILL,7);
   floodfill(110,270,7);

   setcolor(RED);
   settextstyle(1,0,5);
   outtextxy(130,106," NEW ");
   outtextxy(130,161," EASY ");
   outtextxy(130,211," EXIT ");
   outtextxy(95,255," LOAD GAME");
   outtextxy(105,300,"TURNAMENT");
   rectangle(100,100,350,350);
   showmouseptr();
  }
   if(m<105||m>345)
   if(tm!=0)
   tm=0;
    }
   else if(tm!=0)
   tm=0;

 if((button & 1)==1)
 {if(x>=105&&x<=345)
  { if(y>=210&&y<=255)
    break;
    if(y>=105&&y<=155)
    {result=0;
     hidemouseptr();
     new1();
     continue;
      }
    if(y>=160&&y<=250)
    {result=0;
    hidemouseptr();
    easy();
    continue;
    }
   if(y>=260&&y<=305)
   {result=0;
    save2();
    continue; }
   if(y>=310&&y<=345)
   {result=0;
   turna();
   continue;
   }
}}
delay(100);

}
}
int main(int argc, char **argv)
{
 PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);

 int iter = 1;
 double Re = 1;
 double cfl = 10;
 double mu_l = 1.0;
 double rho_l = 1.0;
 //Solver *solverP = new PetscSolver(KSPPREONLY,PCNONE);
 Solver *solverP = new PetscSolver(KSPCG,PCSOR);
 Solver *solverV = new PetscSolver(KSPCG,PCICC);

 const char *binFolder  = "./bin/";
 const char *datFolder  = "./dat/";
 const char *vtkFolder  = "./vtk/";
 const char *simFolder  = "./sim/";

 string meshFile = "disk6-10-20.vtk";
 string meshDir = (string) getenv("DATA_DIR");
 meshDir += "/mesh/3d/" + meshFile;
 const char *mesh = meshDir.c_str();

 Model3D m1;
 m1.setMeshDisk(6,10,10);
 m1.setAdimenDisk();
 m1.setMapping();
#if NUMGLEU == 5
 m1.setMiniElement();
#else
 m1.setQuadElement();
#endif

 m1.setNeighbour();
 m1.setTriEdge();
 m1.setMapEdgeTri();
 m1.setInitSurfaceArea();
 m1.setSurfaceArea();
 m1.setInitSurfaceVolume();
 m1.setSurfaceVolume();
 m1.tetMeshStats();

 Model3D mOld = m1;
 // F, G and H
 m1.setInfiniteSphereBC(0.0,0.0,0.0);
 //m1.setCDiskBC();

 InOut save2(m1); // cria objeto de gravacao
 save2.saveVTK(vtkFolder,"disk");
  
 m1.transformDiskToSphere();

 InOut save3(m1); // cria objeto de gravacao
 save3.saveVTK(vtkFolder,"sphere");

 Simulator3D s1(m1);

 s1.setRe(Re);
 s1.setCfl(cfl);
 s1.setMu(mu_l);
 s1.setRho(rho_l);
 s1.setSolverVelocity(solverV);
 s1.setSolverPressure(solverP);

 s1.init();
 //s1.initDiskBaseState("../../db/baseState/nuCte/","analiticoNuCte.dat");

 s1.setDtEulerian();
 s1.assembleNuCte();
 //s1.assembleC();
 s1.matMount();
 //s1.matMountC();
 s1.setUnCoupledBC(); 
 //s1.setUnCoupledCBC(); 
 
 if( (*(argv+1)) == NULL )
 {
  cout << endl;
  cout << "--------------> STARTING FROM 0" << endl;
  cout << endl;
 }
 else if( strcmp( *(argv+1),"restart") == 0 )
 {
  cout << endl;
  cout << "--------------> RE-STARTING..." << endl;
  cout << endl;

  iter = s1.loadSolution("./","sim",atoi(*(argv+2)));
 }

 InOut save(m1,s1); // cria objeto de gravacao
 save.saveVTK(vtkFolder,"geometry");
 save.saveInfo("./","info",mesh);
 save.printSimulationReport();

 int nIter = 1000;
 int nR = 10;
 for( int i=0;i<nIter;i++ )
 {
  for( int j=0;j<nR;j++ )
  {
   cout << color(none,magenta,black);
   cout << "____________________________________ Iteration: "
	    << i*nR+j+iter << endl << endl;
   cout << resetColor();

   /* dt variable */
   //s1.setDtEulerian();
   //s1.assembleNuCte();
   ////s1.assembleC();
   //s1.matMount();
   ////s1.matMountC();
   //s1.setUnCoupledBC(); 
   //s1.setUnCoupledCBC(); 

   s1.stepSL();
   s1.setRHS();
   //s1.setCRHS();
   s1.unCoupled();
   //s1.unCoupledC();
   save.saveVonKarman(mOld,simFolder,"vk");
//--------------------------------------------------
//    save.saveDiskRadiusError(simFolder,
// 	                        "vkError",
// 							"../../db/baseState/nuCte/analiticoNuCte.dat");
//    save.saveDiskError(datFolder,
// 	                  "diskError",
// 					  "../../db/baseState/nuCte/analiticoNuCte.dat");
//-------------------------------------------------- 
   save.saveConvergence(datFolder,"convergence");

   s1.saveOldData();

   s1.timeStep();

   cout << color(none,magenta,black);
   cout << "________________________________________ END of "
	    << i*nR+j+iter << endl << endl;;
   cout << resetColor();
  }
  save.saveVTK(vtkFolder,"sim",(i+1)*nR+iter-1);
  //save.saveVTKSurface(vtkFolder,"sim",(nR-1)+i*nR+iter-1);
  save.saveSol(binFolder,"sim",(i+1)*nR+iter-1);
  save.printMeshReport();
  save.saveMeshInfo(datFolder);
 }

 PetscFinalize();
 return 0;
}