Exemplo n.º 1
0
        public override void resolve(PROGRAM p, CLASS c, METHOD m)
        {
            base.resolve(p,c,m);
            if ( field == null ) return; // error was detected

            if ( field is FIELD )
            {
                FIELD f = field as FIELD;
                f.type.resolve(p,c,m);
                if ( f.type.classRef != null )
                {
                    member = findFieldInClass(f.type.classRef,sname);
                    if ( member == null ) member = findMethodInClass(f.type.classRef,sname);
                    if ( member == null ) p.errors.issue(21,"field or method",sname);
                    if ( member != null )
                    {
                        if ( member.isStatic ) p.errors.issue(26,member.name);
                        if ( member.isPrivate ) p.errors.issue(27,member,name); // access violation
                    }
                }
                else // a non-class variable in selector
                    p.errors.issue(25);
            }
            else if ( field is CLASS )
            {
                CLASS cls = field as CLASS;
                member = findFieldInClass(cls,sname);
                if ( member == null ) member = findMethodInClass(cls,sname);
                if ( member == null ) p.errors.issue(21,"field or method",name);
                if ( member != null )
                {
                    if ( !member.isStatic ) p.errors.issue(24,member.name);
                    if ( member.isPrivate ) p.errors.issue(27,member.name); // access violation
                }
            }
            else if ( field is METHOD )
                p.errors.issue(25); // a method in the left part of the selector
        }
Exemplo n.º 2
0
 public override void resolve(PROGRAM p, CLASS c, METHOD m)
 {
     if ( m != null ) field = findFieldInMethod(m,name);
     if ( field == null && c != null ) field = findFieldInClass(c,name);
     if ( field == null && c != null ) field = findMethodInClass(c,name);
     if ( field == null ) p.errors.issue(21,"name",name);
     else
     {
         FIELD f = field as FIELD;
         if ( f != null && (f.isLocal || f.isParameter) ) return;
         if ( field is FIELD || field is METHOD )
         {
             if ( field.isStatic && !m.isStatic ) p.errors.issue(28,field.name);
             if ( !field.isStatic && m.isStatic ) p.errors.issue(29,field.name);
         }
     }
 }