Ejemplo n.º 1
0
        public override IList <Executable> ResolveTypes(ParserContext context, VariableScope varScope)
        {
            this.TryCode = Executable.ResolveTypesForCode(this.TryCode, context, new VariableScope(varScope));
            foreach (CatchBlock cb in this.CatchBlocks)
            {
                ResolvedType exceptionType = this.Parent.DoTypeLookupFailSilently(cb.ExceptionType, context);
                if (exceptionType == null)
                {
                    throw new ParserException(cb.ExceptionType.FirstToken, "Exception type not found.");
                }
                if (!exceptionType.IsException(context))
                {
                    throw new ParserException(cb.ExceptionType.FirstToken, "This type does not extend from System.Exception");
                }
                VariableScope catchVarScope = new VariableScope(varScope);
                if (cb.ExceptionVariable != null)
                {
                    catchVarScope.DeclareVariable(cb.ExceptionVariable.Value, exceptionType);
                }
                cb.Code = Executable.ResolveTypesForCode(cb.Code, context, catchVarScope);
            }

            if (this.FinallyCode != null)
            {
                this.FinallyCode = Executable.ResolveTypesForCode(this.FinallyCode, context, new VariableScope(varScope));
            }
            return(Listify(this));
        }