Exemplo n.º 1
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

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

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

            //Check children types
            if (!(LValueNode.TigerType is RecordType))
            {
                report.AddError(SemanticErrors.NonRecordType(LValueNode, LValueNode.TigerType));
            }
            else
            {
                var field = ((RecordType)LValueNode.TigerType).RecordFields.FirstOrDefault(f => f.Name == AttributeNode.Name);
                if (field == null)
                {
                    report.AddError(SemanticErrors.InvalidField(AttributeNode, AttributeNode.Name, LValueNode.TigerType.Name));
                }
                else
                {
                    TigerType = field.TigerType;
                }
            }
        }