Пример #1
0
        internal override void ResolveVariableOrigins(ParserContext parser, VariableScope varIds, VariableIdAllocPhase phase)
        {
            foreach (Executable ex in this.TryBlock)
            {
                ex.ResolveVariableOrigins(parser, varIds, phase);
            }

            foreach (CatchBlock cb in this.CatchBlocks)
            {
                if (cb.ExceptionVariableToken != null)
                {
                    if ((phase & VariableIdAllocPhase.REGISTER) != 0)
                    {
                        // TODO: this is a little flawed. Should find the common base class.
                        AType exceptionType = cb.Types.Length == 1
                            ? AType.ProvideRoot(cb.TypeTokens[0], cb.Types[0])
                            : AType.ProvideRoot(cb.CatchToken, "Core.Exception");
                        varIds.RegisterVariable(exceptionType, cb.ExceptionVariableToken.Value);
                    }

                    if ((phase & VariableIdAllocPhase.ALLOC) != 0)
                    {
                        cb.VariableLocalScopeId = varIds.GetVarId(cb.ExceptionVariableToken);
                    }
                }

                foreach (Executable ex in cb.Code)
                {
                    ex.ResolveVariableOrigins(parser, varIds, phase);
                }
            }

            if (this.FinallyBlock != null)
            {
                foreach (Executable ex in this.FinallyBlock)
                {
                    ex.ResolveVariableOrigins(parser, varIds, phase);
                }
            }
        }