/**
 * 
 */
package StatementClasses;

import BaseClasses.Function;
import BaseClasses.Statement;
import StatementExecuteClasses.Executor;

import java.util.ArrayList;

/**
 * @author viki
 *
 */
public class OverSegStatement extends Statement {
	public OverSegStatement() {
	}

	public boolean executeStatement(){
		boolean result =true;
		System.out.println("execute-OverSegStatement");
		if(Executor.statementArraylist.get(Executor.statementArraylist.size()-1).type==3){//结束if语句
			Executor.waitElse=true;
			Executor.Condition = Executor.statementArraylist.get(Executor.statementArraylist.size()-1).trueOrfalse;
		}

//		else if(Executor.statementArraylist.get(Executor.statementArraylist.size()-1).type==9){//结束函数定义
//			Executor.funcDefFlag=false;
//		}
		if ((Executor.statementArraylist.get(Executor.statementArraylist.size()-1).type==8)){//不是函数定义中的结束
			Executor.removeInvalidVarFunc();
		}
		else {
			if(!isFuncdefOver()){//不是函数定义结束
				Executor.functionArraylist.get(Executor.functionArraylist.size()-1).getFunctionBody().add(new OverSegStatement());
				return result;
			}
		}
		Executor.statementArraylist.remove(Executor.statementArraylist.size()-1);

		return result;
	}
	public boolean isFuncdefOver(){//是不是函数定义结束
		boolean res=false;
		ArrayList<Statement> flist=Executor.functionArraylist.get(Executor.functionArraylist.size()-1).getFunctionBody();
		int statecount=0;
		int overcount=0;
		for (int i=0;i<flist.size();i++){
			if(flist.get(i).getClass().equals(IfStatement.class)||flist.get(i).getClass().equals(ElseStatement.class)
					||(flist.get(i).getClass().equals(ForStatement.class))||(flist.get(i).getClass().equals(WhileStatement.class))
					||(flist.get(i).getClass().equals(SwitchStatement.class))||(flist.get(i).getClass().equals(FuncCallStatement.class))
					||(flist.get(i).getClass().equals(NewSegStatement.class))||(flist.get(i).getClass().equals(FuncDefStatement.class))){
				statecount++;
			}
			else if (flist.get(i).getClass().equals(OverSegStatement.class)){
				overcount++;
			}
		}
		if (statecount==overcount)
			res=true;
		return res;
	}


}

@@ -752,16 +752,38 @@
 e;%0A//%09%09%7D
+%0A%0A%09%09//TODO %E8%BF%99%E9%87%8C%E7%9A%84%E9%80%BB%E8%BE%91%E5%85%B3%E7%B3%BB%E8%A6%81%E6%90%9E%E6%B8%85%E6%A5%9A
 %0A%09%09if ((
@@ -864,22 +864,20 @@
 ==8))%7B//
-%E4%B8%8D%E6%98%AF%E5%87%BD%E6%95%B0%E5%AE%9A%E4%B9%89
+%E5%87%BD%E6%95%B0%E8%B0%83%E7%94%A8
 %E4%B8%AD%E7%9A%84%E7%BB%93%E6%9D%9F%0A%09%09%09
@@ -922,16 +922,115 @@
 %09else %7B%0A
+%09%09%09if (Executor.statementArraylist.get(Executor.statementArraylist.size()-1).type!=9) %7B%0A%0A%09%09%09%7D else%0A
 %09%09%09if(!i
@@ -1393,17 +1393,83 @@
 t%3E flist
-=
+ = null;%0A%09%09if (Executor.functionArraylist.size() %3E 0) %7B%0A%09%09%09flist = 
 Executor
@@ -1516,33 +1516,35 @@
 Arraylist.size()
--
+ - 
 1).getFunctionBo
@@ -1549,16 +1549,48 @@
 Body();%0A
+%09%09%7D else %7B%0A%09%09%09return false;%0A%09%09%7D%0A
 %09%09int st

Fix function Call.