Esempio n. 1
0
 public override Stmt Analy()
 {
     //Condition.IsTopExp = true;
     //Condition = AnalyCondition(Condition, KeyToken.Position);
     //Body.ProcContext = this.ProcContext;
     ConditionExp = ParseAnalyRawExp(Raw.ElseIfExp);
     StmtBody.Analy();
     return(this);
 }
Esempio n. 2
0
 public void AnalyBody()
 {
     Body.ProcContext = this.ProcContext;
     if (this.ProcContext.ClassContext.InitPropertyMethod != null)
     {
         EmitHelper.CallDynamic(Body.IL, this.ProcContext.ClassContext.InitPropertyMethod);
     }
     Body.Analy();
 }
Esempio n. 3
0
 public override Stmt Analy()
 {
     //ConditionExp.IsTopExp = true;
     //ConditionExp.IsTopExp = true;
     ConditionExp = AnalyWhileExpRaw(Raw.ConditionExp);// ParseAnalyRawExp(Raw.ConditionExp);
     ConditionExp = ConditionExp.Analy();
     //WhileBody.ProcContext = this.ProcContext;
     StmtBody.Analy();
     return(this);
 }
Esempio n. 4
0
        public override void Analy( )
        {
            var            tyedimNames = GetTypeWords();
            NameTypeParser parser      = new NameTypeParser(tyedimNames);

            NameTypeParser.ParseResult result = parser.ParseVar(ExceptionTypeVarToken);
            exTypeName = result.TypeName;
            exType     = result.ZType;
            exName     = result.VarName;
            var symbols = this.ProcContext.Symbols;
            //exTypeName = ExceptionTypeToken.GetText();
            //exType = ZTypeCache.GetByZName(exTypeName)[0];

            //if (exType == null)
            //{
            //    errorf(ExceptionTypeToken.Postion, "类型'{0}'不存在", exTypeName);
            //}
            //exName = ExceptionVarToken.GetText();
            var exSymbol2 = symbols.Get(exName);

            if (exSymbol2 == null)
            {
                exSymbol = new SymbolLocalVar(exName, exType);
                exSymbol.LoacalVarIndex = this.ProcContext.CreateLocalVarIndex(exName);
            }
            else
            {
                if (exSymbol2 is SymbolLocalVar)
                {
                    exSymbol = exSymbol2 as SymbolLocalVar;
                    if (exSymbol.SymbolZType != exType)
                    {
                        ErrorE(ExceptionTypeVarToken.Position, "变量'{0}'的类型与异常的类型不一致", exName);
                    }
                }
                else
                {
                    ErrorE(ExceptionTypeVarToken.Position, "变量名称'{0}'已经使用过", exName);
                }
            }
            symbols.Add(exSymbol);
            CatchBody.ProcContext = this.ProcContext;
            CatchBody.Analy();
        }
Esempio n. 5
0
        public override Stmt Analy()
        {
            ForeachListExp = ParseAnalyRawExp(Raw.ListExp);
            CreateEachSymbols();
            var ForeachToken = Raw.LoopToken;
            var ListExp      = Raw.ListExp;
            var ItemToken    = Raw.ItemToken;

            if (ListExp == null)
            {
                Errorf(ForeachToken.Position, "'循环每一个语句'不存在要循环的列表");
            }
            if (ItemToken == null)
            {
                Errorf(ForeachToken.Position, "'循环每一个语句'不存在成员名称");
            }
            if (ListExp == null || ItemToken == null)
            {
                return(null);
            }

            if (!checkCanForeach(ForeachListExp.RetType))
            {
                Errorf(ForeachToken.Position, "该结果不能用作循环每一个");
                return(null);
            }

            if (ZTypeUtil.IsExtends(ForeachListExp.RetType, typeof(列表 <>)))
            {
                startIndex    = 1;
                compareMethod = typeof(Calculater).GetMethod("LEInt", new Type[] { typeof(int), typeof(int) });
            }
            else
            {
                startIndex    = 0;
                compareMethod = typeof(Calculater).GetMethod("LTInt", new Type[] { typeof(int), typeof(int) });
            }
            StmtBody.Analy();
            //Body.ProcContext = this.ProcContext;
            //Body.Analy();
            return(this);
        }
Esempio n. 6
0
        public override Stmt Analy()
        {
            TypeArgParser parser = new TypeArgParser(this.ProcContext.ClassContext);

            TypeArgParser.ParseResult result = parser.Parse(Raw.ExceptionTypeVarToken);
            if (result.ResultCount == 1)
            {
                exTypeName = result.ArgZTypes[0].ZTypeName;
                exType     = (ZLType)result.ArgZTypes[0];
                exName     = result.ArgName;
            }
            if (this.ProcContext.ContainsVarName(exName) == false)
            {
                exSymbol = new ZCLocalVar(exName, exType, true);
                //exSymbol.LoacalVarIndex =this.ProcContext.CreateLocalVarIndex(exName);
                this.ProcContext.AddLocalVar(exSymbol);
            }
            else
            {
                if (this.ProcContext.LocalManager.IsDefLocal(exName))
                {
                    exSymbol = this.ProcContext.LocalManager.GetDefLocal(exName);
                    if (exSymbol.GetZType() != exType)
                    {
                        Errorf(Raw.ExceptionTypeVarToken.Position, "变量'{0}'的类型与异常的类型不一致", exName);
                    }
                }
                else
                {
                    Errorf(Raw.ExceptionTypeVarToken.Position, "变量名称'{0}'已经使用过", exName);
                }
            }
            //CatchBody.ProcContext = this.ProcContext;
            StmtBody.Analy();
            return(this);
        }
Esempio n. 7
0
 public override Stmt Analy()
 {
     //TimesExp.IsTopExp = true;
     TimesExp = AnalyRepeateExpRaw(Raw.TimesExp);// ParseAnalyRawExp(Raw.TimesExp);
     if (TimesExp == null)
     {
         Errorf(Raw.RepeatToken.Position, "重复语句没有表达式");
     }
     else
     {
         TimesExp = TimesExp.Analy();
         if (TimesExp != null && TimesExp.AnalyCorrect)
         {
             if (!ZTypeUtil.IsInt(TimesExp.RetType))
             {
                 Errorf(TimesExp.Position, "结果不是整数");
             }
         }
     }
     CreateEachSymbols();
     //RepeatBody.ProcContext = this.ProcContext;
     RepeatBody.Analy();
     return(this);
 }
Esempio n. 8
0
 public void AnalyBody()
 {
     Body.ProcContext = this.ProcContext;
     Body.Analy();
 }