Changeset 3204 for proto/pabloj/trunk


Ignore:
Timestamp:
May 28, 2013, 9:29:41 AM (6 years ago)
Author:
shermer
Message:

tweak of type classes to implement unification in preparation for semantic analysis.

Location:
proto/pabloj/trunk/src/toolchain/pabloS/lang/type
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/pabloj/trunk/src/toolchain/pabloS/lang/type/PrimitiveType.java

    r3166 r3204  
    1212        VOID,
    1313        INTEGER,
    14         STRINGCONSTANT,
     14        STRING,
    1515        NO_TYPE,        // use as a value when no type has been assigned
    1616        NO_MATCH,       // use as a (unified) value for non-matching types
     
    3030        private PrimitiveType(String infoString) {
    3131                this.infoString = infoString;
    32                
    3332        }
    3433       
    3534        public Type unify(Type otherType) {
    36                 /*
    3735                if(this == otherType || isAcceptableError(otherType)) {
    3836                        return this;
    3937                }
    40                 return NO_MATCH;
    41                 */
    42                
    43                 /* Disallow type unification */
    4438                return NO_MATCH;
    4539        }
  • proto/pabloj/trunk/src/toolchain/pabloS/lang/type/StreamType.java

    r3166 r3204  
    2222        @Override
    2323        public Type unify(Type otherType) {
     24                if(otherType instanceof StreamType) {
     25                        StreamType otherStream = (StreamType)otherType;
     26                        if(otherStream.fieldWidth == fieldWidth) {
     27                                return this;
     28                        }
     29                }
    2430                return PrimitiveType.NO_MATCH;
    2531        }
Note: See TracChangeset for help on using the changeset viewer.