Exemple #1
0
        public static IChelaType GetPrimitiveType(uint id)
        {
            switch ((PrimitiveTypeId)id)
            {
            case PrimitiveTypeId.Void:
                return(ChelaType.GetVoidType());

            case PrimitiveTypeId.UInt8:
                return(ChelaType.GetByteType());

            case PrimitiveTypeId.Int8:
                return(ChelaType.GetSByteType());

            case PrimitiveTypeId.UInt16:
                return(ChelaType.GetUShortType());

            case PrimitiveTypeId.Int16:
                return(ChelaType.GetShortType());

            case PrimitiveTypeId.UInt32:
                return(ChelaType.GetUIntType());

            case PrimitiveTypeId.Int32:
                return(ChelaType.GetIntType());

            case PrimitiveTypeId.UInt64:
                return(ChelaType.GetULongType());

            case PrimitiveTypeId.Int64:
                return(ChelaType.GetLongType());

            case PrimitiveTypeId.Fp32:
                return(ChelaType.GetFloatType());

            case PrimitiveTypeId.Fp64:
                return(ChelaType.GetDoubleType());

            case PrimitiveTypeId.Bool:
                return(ChelaType.GetBoolType());

            case PrimitiveTypeId.Size:
                return(ChelaType.GetSizeType());

            case PrimitiveTypeId.PtrDiff:
                return(ChelaType.GetPtrDiffType());

            case PrimitiveTypeId.Char:
                return(ChelaType.GetCharType());

            default:
                throw new System.NotImplementedException();
            }
        }
        public ModuleTypeDeclaration()
        {
            typeMaps = new Dictionary <string, IChelaType> ();
            typeMaps.Add("Chela.Lang.Object", ChelaType.GetObjectType());
            typeMaps.Add("Chela.Lang.String", ChelaType.GetStringType());

            assocClasses = new Dictionary <string, IChelaType> ();
            assocClasses.Add("Chela.Lang.Boolean", ChelaType.GetBoolType());
            assocClasses.Add("Chela.Lang.Char", ChelaType.GetCharType());
            assocClasses.Add("Chela.Lang.SByte", ChelaType.GetSByteType());
            assocClasses.Add("Chela.Lang.Byte", ChelaType.GetByteType());
            assocClasses.Add("Chela.Lang.Int16", ChelaType.GetShortType());
            assocClasses.Add("Chela.Lang.UInt16", ChelaType.GetUShortType());
            assocClasses.Add("Chela.Lang.Int32", ChelaType.GetIntType());
            assocClasses.Add("Chela.Lang.UInt32", ChelaType.GetUIntType());
            assocClasses.Add("Chela.Lang.Int64", ChelaType.GetLongType());
            assocClasses.Add("Chela.Lang.UInt64", ChelaType.GetULongType());
            assocClasses.Add("Chela.Lang.IntPtr", ChelaType.GetPtrDiffType());
            assocClasses.Add("Chela.Lang.UIntPtr", ChelaType.GetSizeType());
            assocClasses.Add("Chela.Lang.Single", ChelaType.GetFloatType());
            assocClasses.Add("Chela.Lang.Double", ChelaType.GetDoubleType());

            // Vector associated classes
            assocClasses.Add("Chela.Lang.Single2", VectorType.Create(ChelaType.GetFloatType(), 2));
            assocClasses.Add("Chela.Lang.Single3", VectorType.Create(ChelaType.GetFloatType(), 3));
            assocClasses.Add("Chela.Lang.Single4", VectorType.Create(ChelaType.GetFloatType(), 4));
            assocClasses.Add("Chela.Lang.Double2", VectorType.Create(ChelaType.GetDoubleType(), 2));
            assocClasses.Add("Chela.Lang.Double3", VectorType.Create(ChelaType.GetDoubleType(), 3));
            assocClasses.Add("Chela.Lang.Double4", VectorType.Create(ChelaType.GetDoubleType(), 4));
            assocClasses.Add("Chela.Lang.Int32x2", VectorType.Create(ChelaType.GetIntType(), 2));
            assocClasses.Add("Chela.Lang.Int32x3", VectorType.Create(ChelaType.GetIntType(), 3));
            assocClasses.Add("Chela.Lang.Int32x4", VectorType.Create(ChelaType.GetIntType(), 4));
            assocClasses.Add("Chela.Lang.Boolean2", VectorType.Create(ChelaType.GetBoolType(), 2));
            assocClasses.Add("Chela.Lang.Boolean3", VectorType.Create(ChelaType.GetBoolType(), 3));
            assocClasses.Add("Chela.Lang.Boolean4", VectorType.Create(ChelaType.GetBoolType(), 4));
        }
Exemple #3
0
 public DoubleConstant(double value, TokenPosition position)
     : base(position)
 {
     SetNodeType(ConstantType.Create(ChelaType.GetDoubleType()));
     this.value = value;
 }