示例#1
0
/*****************************************************
*				recognize loop & similar statement	 *
******************************************************/
void CompField::VisitLoop(StmtLoop *stmt)		
{

	nbASSERT(stmt != NULL, "StmtLoop cannot be NULL");

	VisitTree(stmt->Forest);				//Visit ..

	VisitTree(stmt->InitVal);			//Visit initialization values


#ifdef DEBUG_COMPACT_FIELDS
	PrintNode(stmt->InitVal,"Debug_List_of_Loop_InitVal.asm",0);
#endif

	if(checkingloop>0)
		ExtractFieldsFromExpr(stmt->InitVal,&m_symboltemp);	//Expression Here!!	


	VisitTree(stmt->TermCond);			//Visit ????

	VisitStatement(stmt->IncStmt);			//Visit increment statements

	VisitCode(stmt->Code->Code);			//Visit loop code

	StartCheck(NULL);

}
示例#2
0
/*****************************************************
*				recognize block statement			 *
*****************************************************/
void CompField::VisitBlock(StmtBlock *stmt)
{
	nbASSERT(stmt != NULL, "StmtBlock cannot be NULL");

	VisitCode(stmt->Code);			//Visit Code inside block

	StartCheck(NULL);
}
示例#3
0
/******************************************************
*				recognize jumps 					  *
******************************************************/
void CompField::VisitJump(StmtJump *stmt)
{
	nbASSERT(stmt != NULL, "JUMP cannot be NULL");

	if (stmt->FalseBranch != NULL)
		VisitTree(stmt->Forest);

	StartCheck(NULL);  //Jump tree is ended-> close compattable list (start before-Jump, end after-jump)
}
示例#4
0
/*****************************************************
*				recognize case	 					 *
*****************************************************/
void CompField::VisitCase(StmtCase *stmt, bool isDefault)
{
	nbASSERT(stmt != NULL, "StmtCase cannot be NULL");

	if (!isDefault)
	{
		VisitTree(stmt->Forest);			//Visit i-case-condition
	}

	StartCheck(NULL);

	if (stmt->Target)
	{
		return;
	}

	VisitCode(stmt->Code->Code);			//Visit code inside this case!!

	StartCheck(NULL);

}
示例#5
0
/*****************************************************
*				recognize switch statement			 *
*****************************************************/
void CompField::VisitSwitch(StmtSwitch *swStmt)
{
	nbASSERT(swStmt != NULL, "StmtSwitch cannot be NULL");


#ifdef DEBUG_COMPACT_FIELDS
	PrintNode(swStmt->Forest,"Debug_List_of_Switch_nodes.asm",0);
#endif
	if(checkingloop>0)
		ExtractFieldsFromExpr(swStmt->Forest,&m_symboltemp);	

	VisitTree(swStmt->Forest);				//Visit SWITCH Condition

	VisitCode(swStmt->Cases);				//Visit Cases

	StartCheck(NULL);

	if (swStmt->Default)					
		VisitCase(swStmt->Default, true);		//Visit Default

	StartCheck(NULL);
}
示例#6
0
/*****************************************************
*				recognize if statement 				 *
******************************************************/
void CompField::VisitIf(StmtIf *stmt)					//[mligios_check]
{
	nbASSERT(stmt != NULL, "StmtIf cannot be NULL");

	VisitTree(stmt->Forest);				//Visit Condition

#ifdef DEBUG_COMPACT_FIELDS
	PrintNode(stmt->Forest,"Debug_List_of_if_nodes.asm",0);
#endif

	if(checkingloop>0)
		ExtractFieldsFromExpr(stmt->Forest,&m_symboltemp);	

	VisitCode(stmt->TrueBlock->Code);			//Visit TRUE block

	StartCheck(NULL);

	if (!stmt->FalseBlock->Code->Empty())				//if exist
	{
		VisitCode(stmt->FalseBlock->Code);		//Visit FALSE block
		StartCheck(NULL);
	}
}
示例#7
0
void CompField::VisitWhileDo(StmtWhile *stmt)
{
	nbASSERT(stmt != NULL, "StmtWhileDo cannot be NULL");

#ifdef DEBUG_COMPACT_FIELDS
	PrintNode(stmt->Forest,"Debug_List_of_WhileDo.asm",0);
#endif
	if(checkingloop>0)
		ExtractFieldsFromExpr(stmt->Forest,&m_symboltemp);	

	VisitTree(stmt->Forest);				//Visit Condition

	VisitCode(stmt->Code->Code);			//Visit Code inside WhileDo

	StartCheck(NULL);	
}
示例#8
0
void TaskFor_SetWork(void *Tags)
{
	uint16 i;
	BOOL WorkTrue=False;
	Tos_ArrayMessage Msg[2];
  MGUI_KeyMsg *KeyMsg,KeyMsgBuf[2];	
	POWER_EN;//OLED电源
	LAMP9_ON;//料罐通电                                                                                                        ;
	LAMP10_ON;//阀门开到位
	LAMP11_ON;//阀门关到位
	LAMP12_ON;//密封到位
	LAMP13_ON;//通信
	LAMP14_OFF;//电源
	LAMP2_ON;//启动
	LAMP3_ON;//强制启动
	Load_Configs();
	Menu_Init(&MenuHome[0]);
	KeyBoard_Configuration();
	Tos_TaskGetHandKey();
	SetKey_WorkMode(KWM_Null);
  Set_Brightness();
  for(i=0;i<2;i++)Msg[i].Qmsg_Addr=&KeyMsgBuf[i];
	Tos_TaskCreateQmsg(&Msg[0],2);
	Run_Value.Status="";
	while(1)
	{
re:		 if(KeyMsg->KeyValue==Key_4)GoTo_Stop();
	 if(WorkTrue==True){Draw_Work();}
		 if(WorkTrue==False){Draw_Home();}
		 SSD1325_OutBuffer();
		 Tos_TaskDelay(1);
      KeyMsg=MUI_GetKey(0);
		 if(KeyMsg)
		 {
			if(KeyMsg->KeyType==KeyBoard_Null)goto re;
			if(WorkTrue==True)
			 {
					if(KeyMsg->KeyType==KeyBoard_Hand)
				{
				Beep_WithKey();
					Run_Value.HeartBeat=0;
					if(KeyMsg->KeyValue==Key_A){Run_Value.Status="开阀";Send_ButtonCommand(OC_UpDoorOpen);}
					if(KeyMsg->KeyValue==Key_B){Run_Value.Status="关阀";Send_ButtonCommand(OC_UpDoorClose);}
					if(KeyMsg->KeyValue==Key_1){Run_Value.Status="开阀";Send_ButtonCommand(OC_DownDoorOpen);}
					if(KeyMsg->KeyValue==Key_3){Run_Value.Status="关阀";Send_ButtonCommand(OC_DownDoorClose);}
					if(KeyMsg->KeyValue==Key_5)TankRelieveClick();
					if(KeyMsg->KeyValue==Key_C)TankPowerClick();
					if(KeyMsg->KeyValue==Key_D){Run_Value.Status="启动";Send_ButtonCommand(OC_Start);Printf_Waiting(String_Wating,10);}//启动
					if(KeyMsg->KeyValue==Key_E){Run_Value.Status="停止";Send_ButtonCommand(OC_Stop);WorkTrue=False;Menu_Init(&MenuHome[0]);Printf_Waiting(String_Wating,10);}//停车
				}
				if(KeyMsg->KeyType==KeyBoard_RockerBar)
				{
					Beep_WithKey();
					Run_Value.HeartBeat=0;
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime<0)&(KeyMsg->KeyTime>-3)){Run_Value.Status="前进";Send_ButtonCommand(OC_TankForward1);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime<-2)&(KeyMsg->KeyTime>-5)){Run_Value.Status="前进";Send_ButtonCommand(OC_TankForward2);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime>0)&(KeyMsg->KeyTime<3)){Run_Value.Status="后退";Send_ButtonCommand(OC_TankBack1);}
					if(KeyMsg->KeyValue==Key_X)if((KeyMsg->KeyTime>2)&(KeyMsg->KeyTime<5)){Run_Value.Status="后退";Send_ButtonCommand(OC_TankBack2);}
					if(KeyMsg->KeyValue==Key_Y)if((KeyMsg->KeyTime<0)){Run_Value.Status="点动";Send_ButtonCommand(OC_TankBackDot);}
				if(KeyMsg->KeyValue==Key_Y)if((KeyMsg->KeyTime>0)){Run_Value.Status="点动";Send_ButtonCommand(OC_TankForwardDot);}
				}
				if(KeyMsg->KeyType==KeyBoard_Null)
				{

				}
			 }
			 if(WorkTrue==False)
			 {
				 if(KeyMsg->KeyType==KeyBoard_Hand)
				{
					Beep_WithKey();
					if(KeyMsg->KeyValue==Key_1){if(PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]--;}
					if(KeyMsg->KeyValue==Key_3){if(PageMenu.OptionLength>PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]++;}
					if(KeyMsg->KeyValue==Key_A)PageMenu.DeepRecord[PageMenu.Index]=0;
					if(KeyMsg->KeyValue==Key_B)Enter_Menu();
					if(KeyMsg->KeyValue==Key_D){Run_Value.Status="启动";WorkTrue=True;Menu_Init(&MenuWork[0]);Send_ButtonCommand(OC_Start);StartCheck();}//启动
					if(KeyMsg->KeyValue==Key_E){Send_ButtonCommand(OC_Stop);}//停车
				}
				if(KeyMsg->KeyType==KeyBoard_RockerBar)
				{
					Beep_WithKey();
					if(KeyMsg->KeyValue==Key_X)Run_Value.HandSpeedX=KeyMsg->KeyTime;
					if(KeyMsg->KeyValue==Key_Y)Run_Value.HandSpeedY=KeyMsg->KeyTime;
					if(KeyMsg->KeyValue==Key_X)if(KeyMsg->KeyTime<0){if(PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]--;}
					if(KeyMsg->KeyValue==Key_X)if(KeyMsg->KeyTime>0){if(PageMenu.OptionLength>PageMenu.DeepRecord[PageMenu.Index])PageMenu.DeepRecord[PageMenu.Index]++;}
					if(KeyMsg->KeyValue==Key_Y)if(KeyMsg->KeyTime<0)PageMenu.DeepRecord[PageMenu.Index]=0;
					if(KeyMsg->KeyValue==Key_Y)if(KeyMsg->KeyTime>0)Enter_Menu();
					
				 }
			 }
		}
		
	}
}
示例#9
0
void CompField::VisitStatement(StmtBase *stmt)
{
	nbASSERT(stmt != NULL , "stmt cannot be NULL");

//Start STATEMENT CHECK:
//if this statement it's not GEN -> means that can't be a DEFFLD! -> we must "close" compattable-fixed-field-list!!!!
	if(stmt->Kind!=STMT_GEN)
		StartCheck(NULL);	
//End of STATEMENT CHECK

	switch(stmt->Kind)
	{
	case STMT_GEN:			//here we recognize FIELD DEFINITIONS -> DEFFLD
	{

		#ifdef DEBUG_COMPACT_FIELDS
		   PrintStmt(stmt,"Debug_Statement_Gen.txt");
		#endif
		VisitTree(stmt->Forest);	
	}break;
	case STMT_JUMP:
	case STMT_JUMP_FIELD:
	{
		VisitJump((StmtJump*)stmt);
	}break;
	case STMT_CASE:	  			//Gettin inside a Case! New "Context"
	{
		VisitCase((StmtCase*)stmt, false);
	}break;
	case STMT_SWITCH: 			//Gettin inside a SWITCH! New "Context"
	{
		VisitSwitch((StmtSwitch*)stmt);
	}break;
	case STMT_IF:  				//Gettin inside an IF! New "Context"
	{
		VisitIf((StmtIf*)stmt);
	}break;
	case STMT_LOOP:  			//only <loop type="times2repeat">
	{
		VisitLoop((StmtLoop*)stmt);
	}break;
	case STMT_WHILE:			//LOOP SIZE -> (CONVERTED) -> STATEMENT WHILE -> i'll convert loop in one variable FIELD (if can)
	{
	
		//if this is Loop-Size (converted in pdlparser to stmtWhile!) -> try compatting, otherwise not! only visit
		
		if(((StmtWhile*)stmt)->isLoopSize==true)	
		{
			
			checkingloop++; 	//Integer USED TO IDENTIFY if This LOOP is the first one or it's an Inner-Loop
			m_loopcomp=1;	

			if(checkingloop>1)	//fields used inside LOOP expression-> If InnerLoop ->need to check it - Otherwise not!
				UpdateMapField((StmtWhile*)stmt);	//ADD field-expr to Local-MAP of Used fields


			VisitWhileDo((StmtWhile*)stmt);		//Visit inside this WHILE 
			if(AllCompattable((StmtWhile*)stmt))//check if the validity of these fields end here or if at least one is also referentiated later
			{
			#ifdef DEBUG_COMPACT_FIELDS
				PrintFieldsMap(&m_DefUseLocal,"Debug_List_of_Fields_Used_insideLoop_Compattable.txt");
			#endif
				/****TRANSFORM LOOP IN A VARIABLE-FIELD****/
				TransformLoop((StmtWhile*)stmt);
			}

			CleanTempMap(&m_symboltemp);	//Clean Used Fields of this loop 
			CleanTempMap(&m_DefUseLocal);	//Clean Used Fields Defined inside this loop

			checkingloop--;
		}
		else
		{
				VisitWhileDo((StmtWhile*)stmt);		//Visit inside this WHILE 			
		}

		}break;
	case STMT_DO_WHILE:   	//Gettin inside a WHILE! New "Context"
	{
		VisitDoWhile((StmtWhile*)stmt);
	}break;
	case STMT_BLOCK:  	//Gettin inside a Block! New "Context"
	{
		VisitBlock((StmtBlock*)stmt);
	}break;
	case STMT_BREAK:			
	case STMT_CONTINUE:		//If Break or Continue (Inside Loops) -> Can't Compact this!! Don't know Total Size!! (Offset)
	{
		//TEMP!! THIS loop must be added to NeverLOOP LIST!!?
		//AddNeverCompattableLoop(actualoop,&m_symboltemp);
		m_loopcomp=0;
	}break;
	case STMT_LABEL:
	case STMT_FINFOST:			
	case STMT_COMMENT:			
	{	
		//Do nothing
	}break;
	default:
		nbASSERT(false, "COMPACT_STMT: CANNOT BE HERE!");
		break;
	}

}
示例#10
0
//[mligios]			REMEMBER INNERFIELDS!!!  m_compatting=0 if previous elements weren't compattable
//If first element compattable 			   -start!
//If element compattable after compattable 	   -continue!
//If element non-compattable after compattable     -stop!
//If element non-compattable after non-compattable -continue!
void CompField::VisitFieldDetails(Node *node)
{
	nbASSERT(node != NULL, "node cannot be NULL");
	nbASSERT(GET_OP(node->Op) == OP_FIELD, "node must be a OP_FIELD");
	nbASSERT(node->Sym->SymKind == SYM_FIELD, "terminal node symbol must be a SYM_FIELD");

	SymbolField *field = (SymbolField*)node->Sym;
	nbASSERT(field != NULL, "field cannot be NULL");

	m_CurrProtoSym=field->Protocol;				//Extract Protocol-Name of This Field


	if(checkingloop>0)	//if -> Inside LoopSize (we don't need to check out used-fields out of loop! -> Useless )
	{
		if(field->Used)		//if -> this field is used?
		{
			//Add To DefUsedMap
			AddFieldToMap((SymbolField *)field,&m_DefUseLocal);
		}	
	}	

	switch(field->FieldType)
	{
		case PDL_FIELD_FIXED:
		{
			SymbolFieldFixed *fixed = (SymbolFieldFixed*)field;
			StartCheck(field);

#ifdef DEBUG_COMPACT_FIELDS	
	PrintSymbol(field,"Debug_List_of_Fixed_Fields.asm");
#endif

			this->VisitInnerFields(fixed);			
		}break;
		case PDL_FIELD_BITFIELD:
		{
#ifdef DEBUG_COMPACT_FIELDS	
	PrintSymbol(field,"Debug_List_of_Bit_Fields.asm");
#endif

//SymbolFieldBitField *bit = (SymbolFieldBitField*)field;
			StartCheck(field);
//TEMP -> bit can't be parent!
//				this->VisitInnerFields(bit);			
		}break;
		case PDL_FIELD_VARLEN:			
		{
#ifdef DEBUG_COMPACT_FIELDS	
	PrintSymbol(field,"Debug_List_of_Variable_Fields.asm");
#endif
			StartCheck(field);
			//extract field from expression!
			Node *expr=((SymbolFieldVarLen *)field)->LenExpr;
			if(checkingloop>0)
			  ExtractFieldsFromExpr(expr,&m_symboltemp);	

		}break;
		case PDL_FIELD_PADDING:
		case PDL_FIELD_TOKEND:
		case PDL_FIELD_TOKWRAP:
		case PDL_FIELD_LINE:
		case PDL_FIELD_PATTERN:
		case PDL_FIELD_EATALL:
		{
			StartCheck(field);
		}break;
		default:
		{
			nbASSERT(false, "What field is this!? (VisitFieldDetails)");			
		}break;
	}

}