Exemple #1
0
 void FlipModifier::Modify(TextureBuffer& Buffer)
 {
     TextureBuffer TempBuffer( Buffer );
     for( Whole Y = 0 ; Y < Buffer.GetHeight() ; ++Y )
     {
         for( Whole X = 0 ; X < Buffer.GetWidth() ; ++X )
         {
             switch( this->FlipAxis )
             {
                 case FlipModifier::PFA_Point:
                 {
                     TempBuffer.SetPixel( Buffer.GetWidth() - 1 - X, Buffer.GetHeight() - 1 - Y, Buffer.GetPixel(X,Y) );
                     break;
                 }
                 case FlipModifier::PFA_Horizontal:
                 {
                     TempBuffer.SetPixel( X, Buffer.GetHeight() - 1 - Y, Buffer.GetPixel(X,Y) );
                     break;
                 }
                 default:
                 case FlipModifier::PFA_Vertical:
                 {
                     TempBuffer.SetPixel( Buffer.GetWidth() - 1 - X, Y, Buffer.GetPixel(X,Y) );
                     break;
                 }
             }
         }
     }
     Buffer.SetData(TempBuffer);
 }
Exemple #2
0
            void RotationZoomModifier::Modify(TextureBuffer& Buffer)
            {
                Whole Width = Buffer.GetWidth();
                Whole Height = Buffer.GetHeight();
                TextureBuffer TempBuffer( Buffer );

                Real fZoomX = MathTools::Pow( 0.5, this->ZoomFactor.X - 1 );
                Real fZoomY = MathTools::Pow( 0.5, this->ZoomFactor.Y - 1 );
                Real RotSin = MathTools::Sin( this->Rotation );
                Real RotCos = MathTools::Cos( this->Rotation );
                Real HalfWidth = static_cast<Real>(Width) * 0.5;
                Real HalfHeight = static_cast<Real>(Height) * 0.5;
                Real XSin = RotSin * -HalfWidth;
                Real XCos = RotCos * -HalfWidth;
                Real YSin = RotSin * -HalfHeight;
                Real YCos = RotCos * -HalfHeight;

                for( Whole Y = 0 ; Y < Buffer.GetHeight() ; ++Y )
                {
                    Real TexU = ( ( XCos - YSin ) * fZoomX ) + ( this->RotationCenter.X * static_cast<Real>(Width) );
                    Real TexV = ( ( XSin + YCos ) * fZoomY ) + ( this->RotationCenter.Y * static_cast<Real>(Height) );
                    for( Whole X = 0 ; X < Buffer.GetWidth() ; ++X )
                    {
                        Real uf = (TexU >= 0) ? (TexU - (Integer)TexU) : 1 + (TexU - (Integer)TexU);
                        Real vf = (TexV >= 0) ? (TexV - (Integer)TexV) : 1 + (TexV - (Integer)TexV);
                        Whole ut = (TexU >= 0) ? (Whole)TexU : (Whole)TexU - 1;
                        Whole vt = (TexV >= 0) ? (Whole)TexV : (Whole)TexV - 1;

                        ColourValue Texel = Buffer.GetPixel( vt % Height, ut % Width ) * ( 1.0 - uf ) * ( 1.0 - vf );
                        Texel += Buffer.GetPixel( vt % Height, ( ut + 1 ) % Width ) * uf * ( 1.0 - vf );
                        Texel += Buffer.GetPixel( ( vt + 1 ) % Height, ut % Width ) * ( 1.0 - uf ) * vf;
                        Texel += Buffer.GetPixel( ( vt + 1 ) % Height, ( ut + 1 ) % Width ) * uf * vf;

                        Texel.RedChannel = std::min(Real(1.0),Texel.RedChannel);
                        Texel.GreenChannel = std::min(Real(1.0),Texel.GreenChannel);
                        Texel.BlueChannel = std::min(Real(1.0),Texel.BlueChannel);
                        Texel.AlphaChannel = std::min(Real(1.0),Texel.AlphaChannel);
                        TempBuffer.SetPixel(X,Y,Texel);

                        TexU += RotCos * fZoomX;
                        TexV += RotSin * fZoomY;
                    }
                    YSin += RotSin;
                    YCos += RotCos;
                }

                Buffer.SetData(TempBuffer);
            }
Exemple #3
0
bool VRSDClient::SendSymbols(int Type, DynArray_cl<VRSDScriptSymbol>& Symbols, unsigned int& SymbolCount, char* pParentSymbol /*= NULL*/)
{
  if(Type != 'LSYC' && Type != 'GSYC' && Type != 'GSSC' && Type != 'LSSC' && Type != 'SMUD')
    return false;

  // create a symbol collection message
  VMessage Msg(Type, SymbolCount * 64);
  Msg.Write(SymbolCount);

  for(unsigned int i = 0; i < SymbolCount; i++)
  {
    // symbol name
    Msg.Write(Symbols[i].GetSymbolName());

    // full symbolname
    if(pParentSymbol)
    {
      VMemoryTempBuffer<512> TempBuffer((int)strlen(pParentSymbol) + (int)strlen(Symbols[i].GetSymbolName()) + 2);
      sprintf(TempBuffer.AsChar(), "%s.%s", pParentSymbol, Symbols[i].GetSymbolName());
      Msg.Write(TempBuffer.AsChar());
    }
    else
    {
      Msg.Write(Symbols[i].GetSymbolName());
    }

    Msg.Write(Symbols[i].GetSymbolContent());
    Msg.Write(Symbols[i].m_eSymbolType);
    Msg.Write(Symbols[i].IsUpdateableByDebugger() ? 1 : 0);
  }

  VMutexLocker lock(m_ConnectionMutex);
  bool bSuccess = m_pConnection && m_pConnection->Send(&Msg);

  return bSuccess;
}
Exemple #4
0
static cchar_t *
ChWStr(const wchar_t *source)
{
    TempBuffer(ChWLen(source), *source++);
}
Exemple #5
0
static cchar_t *
ChStr(const char *source)
{
    TempBuffer(strlen(source), UChar(*source++));
}
Exemple #6
0
CString ExecuteHTTPGet (const CString &sInput)
	{
	//	Parse the input

	char *pPos = sInput.GetParsePointer() + STR_HTTP_GET_PREFIX.GetLength();

	//	Parse the URL

	CString sHost;
	CString sPath;
	if (!urlParse(pPos, NULL, &sHost, &sPath))
		return CString("Invalid URL.");

	//	If no host, then local host

	if (sHost.IsEmpty())
		sHost = CString("localhost");

	//	Connect

	CSocket theSocket;
	if (!theSocket.Connect(sHost, 80))
		return strPattern("Unable to connect to: %s.", sHost);

	//	Compose a request

	CHTTPMessage Request;
	Request.InitRequest(CString("GET"), sPath);
	Request.AddHeader(HEADER_HOST, sHost);
	Request.AddHeader(HEADER_CONNECTION, CString("keep-alive"));
#ifdef DEBUG_REQUEST_FRAGMENT_X
	Request.AddHeader(HEADER_USER_AGENT, CString("AI1/1.0 (This is a test of the header parsing system in Hexarc. There is probably a bug in which splitting the header across packets will cause failure of the HTTP parsing engine.)"));
#else
	Request.AddHeader(HEADER_USER_AGENT, CString("AI1/1.0"));
#endif

	//	Send the request

	CBuffer Buffer(4096);
	Request.WriteToBuffer(Buffer);

#ifdef DEBUG_REQUEST_FRAGMENT
	int iTotalLen = Buffer.GetLength();
	int iSplit = 105;

	if (iSplit < iTotalLen)
		{
		printf("Split at %d bytes\n", iSplit);
		CString sPart(Buffer.GetPointer(), iSplit);
		printf("%s\n", (LPSTR)sPart);

		theSocket.Write(Buffer.GetPointer(), iSplit);
		::Sleep(10);
		theSocket.Write(Buffer.GetPointer() + iSplit, iTotalLen - iSplit);
		}
	else
		theSocket.Write(Buffer.GetPointer(), Buffer.GetLength());
#else
	theSocket.Write(Buffer.GetPointer(), Buffer.GetLength());
#endif

	//	Now read the response. We build up a buffer to hold it.

	CHTTPMessage Response;
	CBuffer ResponseBuff;

	//	Keep reading until we've got enough (or until the connection drops)

	while (!Response.IsMessageComplete())
		{
		CBuffer TempBuffer(8192);

		//	Read

		int iBytesRead = theSocket.Read(TempBuffer.GetPointer(), 8192);
		TempBuffer.SetLength(iBytesRead);

		//	If we're no making progress, then we're done

		if (iBytesRead == 0)
			return strPattern("Unable to read entire message.");

		//	Add to entire buffer

		ResponseBuff.Write(TempBuffer.GetPointer(), iBytesRead);

		//	Parse to see if we're done

		if (!Response.InitFromPartialBuffer(TempBuffer))
			return strPattern("Unable to parse HTTP message.");
		}

	//	Done

	theSocket.Disconnect();

	return CString(ResponseBuff.GetPointer(), ResponseBuff.GetLength());
	}
Exemple #7
0
int  CESBolanStack::PushScript(LPCTSTR ExpStr,CESVariableList* pVariableList,CESFunctionList * pFunctionList,int& LastLine)
{
	TCHAR TempID[MAX_IDENTIFIER_LENGTH];

	CESBolanStack TempStack;
	CESBolanStack OrginScript;
	ES_BOLAN Bolan;
	
	bool IsInStr;
	LastLine=1;

	CEasyBuffer Buffer(((UINT)_tcslen(ExpStr)+1)*sizeof(TCHAR));
	CEasyBuffer TempBuffer(((UINT)_tcslen(ExpStr)+1)*sizeof(TCHAR));

	TCHAR * ExpBuff=(TCHAR *)Buffer.GetBuffer();
	TCHAR * TempBuff=(TCHAR *)TempBuffer.GetBuffer();


	UINT Len=0;
	IsInStr=false;
	while(*ExpStr)
	{
		if(*ExpStr=='"') IsInStr=!IsInStr;

		if(IsInStr)
			ExpBuff[Len++]=(*ExpStr++);
		else
			ExpBuff[Len++]=toupper(*ExpStr++);		

	}
	ExpBuff[Len]=0;
	//CharUpper(ExpBuff);
	ExpStr=ExpBuff;

	//先提取原始布兰式
	while(*ExpStr)
	{
		Bolan.Clear();
		Bolan.Line=LastLine;
		if(*ExpStr==' '||*ExpStr=='\r'||*ExpStr=='\n'||*ExpStr=='	')
		{
			//空格、空行忽略
			if(*ExpStr=='\n')
				LastLine++;
			ExpStr++;
		}
		else if(*ExpStr=='/'&&*(ExpStr+1)=='/')
		{
			while((*ExpStr!='\r')&&(*ExpStr!='\n')&&(*ExpStr))
			{
				if(*ExpStr=='\n')
					LastLine++;
				ExpStr++;
			}
		}
		else if(*ExpStr=='"')//字符串
		{
			UINT i=0;
			ExpStr++;
			while(*ExpStr!='"')
			{
				//if(i>MAX_STRING_LENGTH)
				//	return 1001;
				if(*ExpStr==0)
					return 1002;
				TempBuff[i++]=*ExpStr++;
				if(*ExpStr=='"'&&*(ExpStr+1)=='"')
				{
					TempBuff[i++]=*ExpStr++;
					ExpStr++;
				}
			}
			TempBuff[i]=0;
			ExpStr++;

			Bolan.Type=BOLAN_TYPE_VALUE;
			Bolan.ValueType=VALUE_TYPE_STRING;
			Bolan.StrValue=TempBuff;
			Bolan.Level=0;
			OrginScript.Push(&Bolan);
		}
		else if((*ExpStr>='0'&&*ExpStr<='9')||*ExpStr=='.')	//数字
		{
			UINT i=0;
			while((*ExpStr>='0'&&*ExpStr<='9')||*ExpStr=='.'||*ExpStr=='F'||*ExpStr=='D'||*ExpStr=='I'||*ExpStr=='L'||*ExpStr=='E'||
				*ExpStr=='A'||*ExpStr=='B'||*ExpStr=='C'||*ExpStr=='X')
			{
				TempBuff[i++]=*ExpStr++;
			}
			TempBuff[i]=0;
			Bolan.Type=BOLAN_TYPE_VALUE;			
			Bolan.Level=0;
			StrToNumber(TempBuff,Bolan);
			OrginScript.Push(&Bolan);
		}
		else if(*ExpStr==':')		//跳转标识
		{
			UINT i=0;
			ExpStr++;
			while(CanMakeIdentifier(*ExpStr))
			{
				if(i>MAX_IDENTIFIER_LENGTH)
					return 1003;
				TempID[i++]=*ExpStr++;
			}
			TempID[i]=0;			
			Bolan.Type=BOLAN_TYPE_IDENTIFIER;
			Bolan.Index=IDENTIFIER_TYPE_JUMP_DEFINE;
			Bolan.Level=0;				
			Bolan.StrValue=TempID;
			OrginScript.Push(&Bolan);			
		}
		else if(*ExpStr==';'||*ExpStr=='\r'||*ExpStr=='\n')//行结束符
		{			
			Bolan.Type=BOLAN_TYPE_KEYWORD;
			Bolan.Level=0;
			Bolan.Index=KW_LINEEND;
			OrginScript.Push(&Bolan);
			//除去多余的行结束符
			while(*ExpStr==' '||*ExpStr==';'||*ExpStr=='\r'||*ExpStr=='\n')
			{
				if(*ExpStr=='\n')
					LastLine++;
				ExpStr++;
			}
		}
		else if(*ExpStr>='A'&&*ExpStr<='Z')//标识符
		{
			UINT i=0;
			while(CanMakeIdentifier(*ExpStr))
			{
				if(i>MAX_IDENTIFIER_LENGTH)
					return 1003;
				TempBuff[i++]=*ExpStr++;
			}
			TempBuff[i]=0;	
			if(_tcsicmp(TempBuff,_T("AND"))==0)
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=15;
				Bolan.Index=OPERATOR_AND;
				OrginScript.Push(&Bolan);			
			}
			else if(_tcsicmp(TempBuff,_T("OR"))==0)
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=15;
				Bolan.Index=OPERATOR_OR;
				OrginScript.Push(&Bolan);			
			}
			else if(_tcsicmp(TempBuff,_T("NOT"))==0)
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=16;
				Bolan.Index=OPERATOR_NOT;
				OrginScript.Push(&Bolan);			
			}
			else
			{
				int KeyWord=FindKeyWord(TempBuff);
				if(KeyWord>=0)//关键字
				{
					Bolan.Type=BOLAN_TYPE_KEYWORD;
					Bolan.Level=0;
					Bolan.Index=KeyWord;
					OrginScript.Push(&Bolan);

				}
				else
				{		
					Bolan.Type=BOLAN_TYPE_IDENTIFIER;
					Bolan.Index=IDENTIFIER_TYPE_UNKNOW;
					Bolan.Level=0;				
					Bolan.StrValue=TempBuff;
					OrginScript.Push(&Bolan);					
				}
			}
		}
		else if(*ExpStr=='(')
		{			
			Bolan.Type=BOLAN_TYPE_OPERATOR;
			Bolan.Level=0;
			Bolan.Index=OPERATOR_LP;
			OrginScript.Push(&Bolan);
			ExpStr++;			
		}
		else if(*ExpStr==')')
		{
			Bolan.Type=BOLAN_TYPE_OPERATOR;
			Bolan.Level=0;
			Bolan.Index=OPERATOR_RP;
			OrginScript.Push(&Bolan);
			ExpStr++;
		}
		else if(*ExpStr=='=')
		{	
			if(*(ExpStr+1)=='=')
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_EQU;	
				OrginScript.Push(&Bolan);
				ExpStr+=2;
			}
			else
			{					
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=10;
				Bolan.Index=OPERATOR_EVA;	
				OrginScript.Push(&Bolan);
				ExpStr++;
			}
		}
		else if(*ExpStr=='>')
		{			
			if(*(ExpStr+1)=='=')
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_MORE_EQU;	
				OrginScript.Push(&Bolan);
				ExpStr+=2;	
			}
			else
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_MORE;	
				OrginScript.Push(&Bolan);
				ExpStr++;				
			}
		}
		else if(*ExpStr=='<')
		{			
			if(*(ExpStr+1)=='=')
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_LESS_EQU;		
				OrginScript.Push(&Bolan);
				ExpStr+=2;	
			}
			else if(*(ExpStr+1)=='>')
			{				
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_DIFF;		
				OrginScript.Push(&Bolan);
				ExpStr+=2;	
			}
			else
			{					
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=20;
				Bolan.Index=OPERATOR_LESS;			
				OrginScript.Push(&Bolan);
				ExpStr++;				
			}			

		}
		else if(*ExpStr=='+'||*ExpStr=='-')
		{
			//if(*ExpStr=='-'&&(ExpStr==ExpBuff||*(ExpStr-1)=='('))
			//{				
			//	Bolan.Type=BOLAN_TYPE_OPERATOR;
			//	Bolan.Index=OPERATOR_NEG;
			//	Bolan.Level=50;
			//	OrginScript.Push(&Bolan);
			//	ExpStr++;
			//}
			//else
			{						
				Bolan.Type=BOLAN_TYPE_OPERATOR;
				Bolan.Level=30;
				if(*ExpStr=='+') Bolan.Index=OPERATOR_ADD;
				else Bolan.Index=OPERATOR_SUB;	
				OrginScript.Push(&Bolan);
				ExpStr++;				
			}
		}
		else if(*ExpStr=='*'||*ExpStr=='/')
		{						
			Bolan.Type=BOLAN_TYPE_OPERATOR;
			Bolan.Level=40;
			if(*ExpStr=='*') Bolan.Index=OPERATOR_MUL;
			else Bolan.Index=OPERATOR_DIV;	
			OrginScript.Push(&Bolan);
			ExpStr++;
		}
		else if(*ExpStr==',')
		{
			Bolan.Type=BOLAN_TYPE_OPERATOR;
			Bolan.Index=OPERATOR_COMMA;
			Bolan.Level=0;
			OrginScript.Push(&Bolan);			
			ExpStr++;
		}		
		else
		{
			return 1005;				//非法字符
		}		
	}

	CESThread ESThread;

	ESThread.SetScript(&OrginScript);
	ESThread.SetVariableList(pVariableList);
	ESThread.SetFunctionList(pFunctionList);

	int RetCode=DealIdentifiers(&ESThread);
	LastLine=ESThread.GetLastLine();
	if(RetCode)
		return RetCode;

	

	
	for(UINT i=0;i<OrginScript.GetSize();i++)
	{
		ES_BOLAN * pBolan=OrginScript.GetAt(i);
		LastLine=pBolan->Line;
		switch(pBolan->Type)
		{
		case BOLAN_TYPE_VALUE:
			Push(pBolan);
			break;
		case BOLAN_TYPE_OPERATOR:
			if(pBolan->Index==OPERATOR_RP)
			{
				while(TempStack.GetTop()!=NULL&&(TempStack.GetTop()->Type!=BOLAN_TYPE_OPERATOR||TempStack.GetTop()->Index!=OPERATOR_LP))
				{				
					ES_BOLAN * pTemp=TempStack.Pop();					
					Push(pTemp);
				}			
				if(TempStack.GetTop()==NULL||TempStack.GetTop()->Type!=BOLAN_TYPE_OPERATOR||TempStack.GetTop()->Index!=OPERATOR_LP)
					return 2021;
				TempStack.Pop();
			}
			else if(pBolan->Index==OPERATOR_LP)
			{
				TempStack.Push(pBolan);
			}			
			else if(pBolan->Index==OPERATOR_NOP)
			{

			}
			else if(pBolan->Index==OPERATOR_COMMA)
			{
				while(TempStack.GetTop()!=NULL&&(TempStack.GetTop()->Type!=BOLAN_TYPE_OPERATOR||TempStack.GetTop()->Index!=OPERATOR_LP))
				{				
					ES_BOLAN * pTemp=TempStack.Pop();					
					Push(pTemp);
				}	
			}
			else
			{
				while(TempStack.GetTop()!=NULL&&TempStack.GetTop()->Level>=pBolan->Level)
				{		
					ES_BOLAN * pTemp=TempStack.Pop();				
					Push(pTemp);
				}	
				TempStack.Push(pBolan);
			}
			break;
		case BOLAN_TYPE_FUNCTION:
			while(TempStack.GetTop()!=NULL&&TempStack.GetTop()->Level>=pBolan->Level)
			{		
				ES_BOLAN * pTemp=TempStack.Pop();				
				Push(pTemp);
			}		
			TempStack.Push(pBolan);
			break;
		case BOLAN_TYPE_VARIABLE:
			Push(pBolan);
			break;
		case BOLAN_TYPE_KEYWORD:
			while(TempStack.GetTop()!=NULL)
			{		
				ES_BOLAN * pTemp=TempStack.Pop();			
				Push(pTemp);
			}	
			switch(pBolan->Index)
			{
			case KW_EXIT:
			case KW_IF:			
			case KW_THEN:
			case KW_ELSE:
			case KW_ELSEIF:				
			case KW_ENDIF:
			case KW_WHILE:				
			case KW_DO:				
			case KW_ENDWHILE:				
			case KW_BREAK:				
			case KW_CONTINUE:				
			case KW_GOTO:
				Push(pBolan);
				break;
			case KW_LINEEND:				
			case KW_INT:
			case KW_INT64:
			case KW_FLOAT:
			case KW_DOUBLE:
			case KW_STRING:				
				break;
			case KW_FUNCTION:				
			case KW_ENDFUN:				
				Push(pBolan);
				break;
			};			
			break;
		case BOLAN_TYPE_IDENTIFIER:
			while(TempStack.GetTop()!=NULL)
			{		
				ES_BOLAN * pTemp=TempStack.Pop();				
				Push(pTemp);
			}
			if(pBolan->Index!=IDENTIFIER_TYPE_VARIABLE_DEFINE)
				Push(pBolan);
			break;
		}
	}
	while(TempStack.GetTop()!=NULL)
	{		
		ES_BOLAN * pTemp=TempStack.Pop();
		if(pTemp->Type==BOLAN_TYPE_OPERATOR&&pTemp->Index==OPERATOR_LP)
			return 2021;
		Push(pTemp);
	}

	//设置各种控制语句
	ES_FUNCTION * pCurFunction=NULL;	

	for(UINT i=0;i<GetSize();i++)
	{
		ES_BOLAN * pBolan=GetAt(i);
		LastLine=pBolan->Line;
		if(pBolan->Type==BOLAN_TYPE_FUNCTION)
		{
			pBolan->Type=BOLAN_TYPE_OPERATOR;
			pBolan->Level=pBolan->Index;
			pBolan->Index=OPERATOR_CALL;
		}
		else if(pBolan->Type==BOLAN_TYPE_KEYWORD)
		{
			switch(pBolan->Index)
			{
			case KW_EXIT:
				pBolan->Type=BOLAN_TYPE_OPERATOR;
				pBolan->Index=OPERATOR_EXIT;
				break;
			case KW_IF:
			case KW_ELSEIF:
				{
					int EndPos=FindCoupleKeyWord(KW_ENDIF,KW_IF,KW_ENDIF,i+1);
					if(EndPos<0)
						return 2001;
					if(pBolan->Index==KW_ELSEIF)
					{
						pBolan->Type=BOLAN_TYPE_OPERATOR;
						pBolan->Index=OPERATOR_JMP;
						pBolan->Level=EndPos+1;
					}
					int Pos=GetNextKeyWord(i+1);
					if(Pos<0)
						return 2001;
					ES_BOLAN * pThenBolan=GetAt(Pos);
					if(pThenBolan->Type!=BOLAN_TYPE_KEYWORD&&pThenBolan->Index!=KW_THEN)
						return 2001;
					int ElseIfPos=FindCoupleKeyWord(KW_ELSEIF,KW_IF,KW_ENDIF,i+1,EndPos+1);
					int ElsePos=FindCoupleKeyWord(KW_ELSE,KW_IF,KW_ENDIF,i+1,EndPos+1);
					pThenBolan->Type=BOLAN_TYPE_OPERATOR;
					pThenBolan->Index=OPERATOR_JZ;
					if(ElseIfPos>=0)
						pThenBolan->Level=ElseIfPos+1;
					else if(ElsePos>=0)
						pThenBolan->Level=ElsePos+1;
					else
						pThenBolan->Level=EndPos+1;
				}					
				break;
			case KW_ELSE:
				{
					int EndPos=FindCoupleKeyWord(KW_ENDIF,KW_IF,KW_ENDIF,i+1);
					if(EndPos<0)
						return 2001;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_JMP;
					pBolan->Level=EndPos+1;
				}
				break;
			case KW_WHILE:
				{
					int Pos=GetNextKeyWord(i+1);
					if(Pos<0)
						return 2011;
					ES_BOLAN * pDoBolan=GetAt(Pos);
					if(pDoBolan->Type!=BOLAN_TYPE_KEYWORD||pDoBolan->Index!=KW_DO)
						return 2011;
					Pos=FindCoupleKeyWord(KW_ENDWHILE,KW_WHILE,KW_ENDWHILE,i+1);
					if(Pos<0)
						return 2011;
					ES_BOLAN * pEndBolan=GetAt(Pos);
					pDoBolan->Type=BOLAN_TYPE_OPERATOR;
					pDoBolan->Index=OPERATOR_JZ;
					pDoBolan->Level=Pos+1;
					pEndBolan->Type=BOLAN_TYPE_OPERATOR;
					pEndBolan->Index=OPERATOR_JMP;
					pEndBolan->Level=i+1;
				}
				break;			
			case KW_ENDWHILE:
				{
					return 2011;
					//int Pos=FindCoupleKeyWordReverse(KW_WHILE,KW_WHILE,KW_ENDWHILE,i-1);
					//if(Pos<0)
					//	return 2011;
					//pBolan->Type=BOLAN_TYPE_OPERATOR;
					//pBolan->Index=OPERATOR_JMP;
					//pBolan->Level=Pos+1;
				}
				break;
			case KW_BREAK:
				{
					int Pos=FindCoupleKeyWord(KW_ENDWHILE,KW_WHILE,KW_ENDWHILE,i);
					if(Pos<0)
						return 2012;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_JMP;
					pBolan->Level=Pos+1;
				}
				break;
			case KW_CONTINUE:
				{
					int Pos=FindCoupleKeyWordReverse(KW_WHILE,KW_WHILE,KW_ENDWHILE,i);
					if(Pos<0)
						return 2013;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_JMP;
					pBolan->Level=Pos+1;
				}
				break;
			case KW_GOTO:
				{
					ES_BOLAN *pIDBolan=GetAt(i+1);
					if(pIDBolan==NULL)
						return 2014;
					if(pIDBolan->Type!=BOLAN_TYPE_IDENTIFIER)
						return 2014;
					int Pos=FindIdentifier(0,pIDBolan->StrValue);
					if(Pos<0)
						return 2015;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_JMP;
					pBolan->Level=Pos+1;
				}
				break;
			case KW_FUNCTION:
				{
					int Pos=FindKeyWord(KW_ENDFUN,i,-1);
					if(Pos<0)
						return 2016;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_JMP_FUNC;
					pBolan->Level=Pos+1;

					
				}
				break;
			case KW_ENDFUN:
				{					
					if(pCurFunction==NULL)
						return 2019;					
					pCurFunction->FunEndPos=i+1;
					pBolan->Type=BOLAN_TYPE_OPERATOR;
					pBolan->Index=OPERATOR_RET;
				}
				break;				
			}
		}
		else if(pBolan->Type==BOLAN_TYPE_IDENTIFIER&&pBolan->Index==IDENTIFIER_TYPE_FUNCTION_DEFINE)
		{
			pCurFunction=pFunctionList->FindFunction(pBolan->StrValue);
			if(pCurFunction==NULL)
			{
				return 2019;
			}
			if(pCurFunction->Type!=FUNCTION_TYPE_SCRIPT)
			{
				return 2019;
			}
			pCurFunction->FunStartPos=i;

			//反转函数参数顺序
			RetCode=ReverseFunctionParam(this,i+1,pCurFunction->ParaCount);
			if(RetCode)
				return RetCode;
		}
	}

	//删除多余的布兰式
	for(int i=(int)GetSize()-1;i>=0;i--)
	{
		ES_BOLAN * pBolan=GetAt(i);
		if(pBolan->Type!=BOLAN_TYPE_VALUE&&
			pBolan->Type!=BOLAN_TYPE_OPERATOR&&
			pBolan->Type!=BOLAN_TYPE_VARIABLE&&(pBolan->Type!=BOLAN_TYPE_KEYWORD||pBolan->Index!=KW_FUNCTION))
		{
			DeleteBolan(this,pFunctionList,i);
		}
	}

	//进行变量绑定

	ESThread.SetScript(this);
	RetCode=DoVariableBind(&ESThread,LastLine);
	if(RetCode)
		return RetCode;

	return 0;
	
}