コード例 #1
0
        public MosaType GetTypeFromTypeCode(MosaTypeCode code)
        {
            switch (code)
            {
            case MosaTypeCode.Void: return(TypeSystem.BuiltIn.Void);

            case MosaTypeCode.Boolean: return(TypeSystem.BuiltIn.Boolean);

            case MosaTypeCode.Char: return(TypeSystem.BuiltIn.Char);

            case MosaTypeCode.I1: return(TypeSystem.BuiltIn.I1);

            case MosaTypeCode.U1: return(TypeSystem.BuiltIn.U1);

            case MosaTypeCode.I2: return(TypeSystem.BuiltIn.I2);

            case MosaTypeCode.U2: return(TypeSystem.BuiltIn.U2);

            case MosaTypeCode.I4: return(TypeSystem.BuiltIn.I4);

            case MosaTypeCode.U4: return(TypeSystem.BuiltIn.U4);

            case MosaTypeCode.I8: return(TypeSystem.BuiltIn.I8);

            case MosaTypeCode.U8: return(TypeSystem.BuiltIn.U8);

            case MosaTypeCode.R4: return(TypeSystem.BuiltIn.R4);

            case MosaTypeCode.R8: return(TypeSystem.BuiltIn.R8);

            case MosaTypeCode.I: return(TypeSystem.BuiltIn.I);

            case MosaTypeCode.U: return(TypeSystem.BuiltIn.U);

            case MosaTypeCode.String: return(TypeSystem.BuiltIn.String);

            case MosaTypeCode.TypedRef: return(TypeSystem.BuiltIn.TypedRef);

            case MosaTypeCode.Object: return(TypeSystem.BuiltIn.Object);
            }

            throw new CompilerException("Can't convert type code {code} to type");
        }
コード例 #2
0
 public static MosaType GetTypeFromTypeCode(this TypeSystem typeSystem, MosaTypeCode code)
 {
     switch (code)
     {
         case MosaTypeCode.Void: return typeSystem.BuiltIn.Void;
         case MosaTypeCode.Boolean: return typeSystem.BuiltIn.Boolean;
         case MosaTypeCode.Char: return typeSystem.BuiltIn.Char;
         case MosaTypeCode.I1: return typeSystem.BuiltIn.I1;
         case MosaTypeCode.U1: return typeSystem.BuiltIn.U1;
         case MosaTypeCode.I2: return typeSystem.BuiltIn.I2;
         case MosaTypeCode.U2: return typeSystem.BuiltIn.U2;
         case MosaTypeCode.I4: return typeSystem.BuiltIn.I4;
         case MosaTypeCode.U4: return typeSystem.BuiltIn.U4;
         case MosaTypeCode.I8: return typeSystem.BuiltIn.I8;
         case MosaTypeCode.U8: return typeSystem.BuiltIn.U8;
         case MosaTypeCode.R4: return typeSystem.BuiltIn.R4;
         case MosaTypeCode.R8: return typeSystem.BuiltIn.R8;
         case MosaTypeCode.I: return typeSystem.BuiltIn.I;
         case MosaTypeCode.U: return typeSystem.BuiltIn.U;
         case MosaTypeCode.String: return typeSystem.BuiltIn.String;
         case MosaTypeCode.TypedRef: return typeSystem.BuiltIn.TypedRef;
         case MosaTypeCode.Object: return typeSystem.BuiltIn.Object;
     }
     throw new CompilerException("Can't convert type code '" + code + "' to type.");
 }