Пример #1
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

            //Check children
            LValueNode.CheckSemantics(scope, report);
            IndexExpressionNode.CheckSemantics(scope, report);

            if (!LValueNode.IsOK || !IndexExpressionNode.IsOK)
            {
                return;
            }

            //Check children types
            if (!(LValueNode.TigerType is ArrayType))
            {
                report.AddError(SemanticErrors.NonArrayType(LValueNode, LValueNode.TigerType));
                return;
            }
            if (!TigerType.Int.Assignable(IndexExpressionNode.TigerType))
            {
                report.AddError(SemanticErrors.ArrayIndexerInvalidType(IndexExpressionNode, IndexExpressionNode.TigerType));
                return;
            }

            TigerType = ((ArrayType)LValueNode.TigerType).ContentType;
        }