예제 #1
0
        public void VisitNode(AssignmentExpr node)
        {
            String RHS_Type;

            Utilities.TypeVisitAllChildren(node);

            Attributes a = new Attributes("Assignment");
            AssignmentTypeDescriptor ATD = new AssignmentTypeDescriptor();

            // Get Qualified Name
            List <QualifiedName> matchingChildren = Utilities.GetChildren(node, typeof(QualifiedName)).Cast <QualifiedName>().ToList();

            ATD.LHS_Type = Utilities.attrToType(matchingChildren[0].attrRef);

            RHS_Type     = ATD.LHS_Type;
            a.typeInfo   = ATD;
            node.attrRef = a;

            // Error type if problem with assignment
            if (IsAssignable(ATD.LHS_Type, node, ref RHS_Type) == false)
            {
                Error(String.Format("Warning! Cannot assign {0} to {1}", RHS_Type, ATD.LHS_Type));
                node.attrRef.typeInfo = new ErrorTypeDescriptor();
            }
            ATD.RHS_Type = RHS_Type;
        }
예제 #2
0
        public override String AttrPrint()
        {
            String retVal;

            if (Utilities.attrToType(this.attrRef) == "ErrorTypeDescriptor")
            {
                retVal = String.Format("{0} (assignment impossible)", Utilities.attrToType(this.attrRef));
            }
            else
            {
                AssignmentTypeDescriptor ATD = this.attrRef.typeInfo;

                retVal = String.Format("{0} \n {1} assigned to {2}", Utilities.attrToType(this.attrRef), ATD.LHS_Type, ATD.RHS_Type);
            }
            return(retVal);
        }