Пример #1
0
 //Constructor for Enumeration
 public SimpleType(string name, List<string> options)
 {
     Name = name;
     _restriction = Restriction.Enumeration;
     _basicType = BasicType.String;
     _options = options;
 }
Пример #2
0
 private BuiltInsMethodCall(MethodInfo method)
     : base(LineId.None)
 {
     this.method = method;
     if (this.method.ReturnType == typeof(string)) type = BasicType.String;
     else type = BasicType.Number;
 }
Пример #3
0
 public override BasicType GetBasicType()
 {
     valueType = value.GetBasicType();
     if (valueType == BasicType.Number || valueType == BasicType.Boolean)
         type = BasicType.Number;
     else type = BasicType.Error;
     return type;
 }
Пример #4
0
        public override void CheckTypes()
        {
            exprType = conditional.GetBasicType();

            if (conditional.GetBasicType() == BasicType.Number ||
                conditional.GetBasicType() == BasicType.Boolean) return;
            throw new Exception(String.Format("Type error in conditional of If on {0}", line.Label));
        }
 public static extern void glslopt_shader_get_input_desc(IntPtr shader,
     int index,
     out IntPtr outName,
     out BasicType outType,
     out Precision outPrec,
     out int outVecSize,
     out int outMatSize,
     out int outArraySize,
     out int outLocation);
Пример #6
0
 public override void CheckTypes()
 {
     if (seedSpecified)
     {
         exprType = seedExpression.GetBasicType();
         if (exprType == BasicType.Number || exprType == BasicType.Boolean) return;
         throw new Exception("Type error");
     }
 }
Пример #7
0
        /// <summary>
        ///     初始化
        /// </summary>
        /// <param name="value"></param>
        public BsonValueEx(BsonValue value)
        {
            if (value.IsString)
            {
                mBsonType = BasicType.BsonString;
                mBsonString = value.ToString();
            }

            if (value.IsInt32)
            {
                mBsonType = BasicType.BsonInt32;
                mBsonInt32 = value.AsInt32;
            }
            if (value.IsInt64)
            {
                mBsonType = BasicType.BsonInt64;
                mBsonInt64 = value.AsInt64;
            }

            if (value.IsDecimal128)
            {
                mBsonType = BasicType.BsonDecimal128;
                mBSonDecimal128 = value.AsDecimal;
            }
            if (value.IsDouble)
            {
                mBsonType = BasicType.BsonDouble;
                mBsonDouble = value.AsDouble;
            }

            if (value.IsValidDateTime)
            {
                mBsonType = BasicType.BsonDateTime;
                mBsonDateTime = value.ToUniversalTime();
            }
            if (value.IsBoolean)
            {
                mBsonType = BasicType.BsonBoolean;
                mBsonBoolean = value.AsBoolean;
            }

            if (value.IsBsonMaxKey)
            {
                mBsonType = BasicType.BsonMaxKey;
            }
            if (value.IsBsonMinKey)
            {
                mBsonType = BasicType.BsonMinKey;
            }

            if (value.IsBsonBinaryData)
            {
                mBsonType = BasicType.BsonBinary;
                mBsonBinary = value.AsBsonBinaryData.Bytes;
            }
        }
Пример #8
0
        public void EqualExpr()
        {
            var cfb    = GetConstantFoldingBuilder();
            var id     = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var result = cfb.BVSGE(id, id);

            CheckIsBoolType(result);
            Assert.IsNotNull(ExprUtil.AsLiteral(result));
            Assert.IsTrue(ExprUtil.IsTrue(result));
        }
Пример #9
0
        public void AsNotEqWithNotEq()
        {
            var sb      = GetSimpleBuilder();
            var v       = GetVarAndIdExpr("foo", BasicType.GetBvType(4)).Item2;
            var e       = sb.NotEq(v, sb.ConstantBV(0, 4));
            var asNotEq = ExprUtil.AsNotEq(e);

            Assert.IsNotNull(asNotEq);
            Assert.AreSame(e, asNotEq);
        }
Пример #10
0
 public override BasicType GetBasicType()
 {
     if (s1.GetBasicType() == BasicType.String &&
         s2.GetBasicType() == BasicType.String)
     {
         type = BasicType.String;
         return type;
     }
     return BasicType.Error;
 }
Пример #11
0
        public void DivideByOne()
        {
            var cfb      = GetConstantFoldingBuilder();
            var dividend = GetVarAndIdExpr("x", BasicType.GetBvType(4)).Item2;
            var divisor  = cfb.ConstantBV(1, 4);
            var result   = cfb.BVSDIV(dividend, divisor);

            Assert.IsTrue(ExprUtil.StructurallyEqual(result, dividend));
            CheckIsBvType(result, 4);
        }
Пример #12
0
        public void SameExprAdded()
        {
            var cfb    = GetConstantFoldingBuilder();
            var x      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var y      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var result = cfb.BVSUB(x, x);

            Assert.IsNotNull(ExprUtil.AsLiteral(result));
            CheckIsBvType(result, 8);
            Assert.IsTrue(ExprUtil.IsZero(result));
        }
Пример #13
0
        public override Type VisitBasicType(BasicType node)
        {
            //only support integers and booleans as basic types
            if (node.IsReal || node.isFloat || node.IsBv || node.IsString || node.IsRMode || node.IsRegEx)
            {
                problematicNode = node;
                return(node);
            }

            return(base.VisitBasicType(node));
        }
Пример #14
0
        public void ConcatExtractsToOriginal()
        {
            var cfb    = GetConstantFoldingBuilder();
            var id     = GetVarAndIdExpr("x", BasicType.GetBvType(16)).Item2;
            var msb    = cfb.BVEXTRACT(id, 16, 8);
            var lsb    = cfb.BVEXTRACT(id, 8, 0);
            var result = cfb.BVCONCAT(msb, lsb);

            CheckIsBvType(result, 16);
            Assert.AreSame(id, result);
        }
Пример #15
0
        public void IfFalse()
        {
            var  cfb    = GetConstantFoldingBuilder();
            var  id0    = GetVarAndIdExpr("foo", BasicType.GetBvType(8)).Item2;
            var  id1    = GetVarAndIdExpr("bar", BasicType.GetBvType(8)).Item2;
            Expr result = cfb.IfThenElse(Expr.False, id0, id1);

            Assert.AreEqual("bar", result.ToString());
            CheckIsBvType(result, 8);
            Assert.AreSame(result, id1);
        }
Пример #16
0
        private bool CheckRepeat(BasicType model)
        {
            var query   = Query.And(Query.EQ("Num", model.Num), Query.EQ("TypeId", model.TypeId));
            var modelDb = _bll.Get(query);

            if (modelDb == null)
            {
                return(true);
            }
            return(model.Rid == modelDb.Rid);
        }
Пример #17
0
        public void XorWithSameExpr()
        {
            var cfb    = GetConstantFoldingBuilder();
            var id     = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var result = cfb.BVXOR(id, id);

            CheckIsBvType(result, 8);
            var resultAsLit = ExprUtil.AsLiteral(result);

            Assert.IsTrue(ExprUtil.IsZero(resultAsLit));
        }
Пример #18
0
        public void mulByRhsZero()
        {
            var cfb    = GetConstantFoldingBuilder();
            var x      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var result = cfb.BVMUL(x, cfb.ConstantBV(0, 8));

            CheckIsBvType(result, 8);
            var asLit = ExprUtil.AsLiteral(result);

            Assert.IsNotNull(asLit);
            Assert.IsTrue(ExprUtil.IsZero(asLit));
        }
Пример #19
0
        private ParameterString GetParameterString(ParameterValue parameter, BasicType basicType)
        {
            if (parameter != null)
            {
                if (parameter.PropertyId.HasValue)
                {
                    return(new ParameterString()
                    {
                        IsFromModel = true,
                        Value = _modelRepository.GetProperty(parameter.PropertyId.Value).Name
                    });
                }
                else
                {
                    var parameterString = new ParameterString()
                    {
                        IsFromModel = false
                    };
                    switch (basicType)
                    {
                    case (BasicType.Int):
                        if (parameter.IntValue.HasValue)
                        {
                            parameterString.Value = parameter.IntValue.Value.ToString();
                        }
                        break;

                    case (BasicType.String):
                        parameterString.Value = parameter.StringValue;
                        break;

                    case (BasicType.Bool):
                        if (parameter.BoolValue.HasValue)
                        {
                            parameterString.Value = parameter.BoolValue.Value.ToString();
                        }
                        break;

                    case (BasicType.DateTime):
                        if (parameter.DateTimeValue.HasValue)
                        {
                            parameterString.Value = parameter.DateTimeValue.Value.ToString();
                        }
                        break;
                    }
                    return(parameterString);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #20
0
        public void IfConditionThenTrueElseFalse()
        {
            var builder   = GetConstantFoldingBuilder();
            var id0       = GetVarAndIdExpr("foo", BasicType.GetBvType(8)).Item2;
            var id1       = GetVarAndIdExpr("bar", BasicType.GetBvType(8)).Item2;
            var condition = builder.Eq(id0, id1);
            var result    = builder.IfThenElse(condition, builder.True, builder.False);

            CheckIsBoolType(result);
            Assert.IsNull(ExprUtil.AsLiteral(result));
            Assert.AreSame(condition, result);
        }
Пример #21
0
        /// <summary>
        /// 获取表名
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private string GetTypeTableName(BasicType type)
        {
            switch (type)
            {
            case BasicType.SubType:
                return("SubjectType");

            case BasicType.SubLevel:
                return("SubjectLevel");
            }
            return(null);
        }
Пример #22
0
        public void lhsIsZero()
        {
            var cfb    = GetConstantFoldingBuilder();
            var x      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var result = cfb.BVSUB(cfb.ConstantBV(0, 8), x);

            CheckIsBvType(result, 8);
            var asBvNeg = ExprUtil.AsBVNEG(result);

            Assert.IsNotNull(asBvNeg);
            Assert.AreSame(x, asBvNeg.Args[0]);
        }
Пример #23
0
 public void RemByOne()
 {
     var cfb = GetConstantFoldingBuilder();
     var dividend = GetVarAndIdExpr("x", BasicType.GetBvType(4)).Item2;
     var divisor = cfb.ConstantBV(1, 4);
     var result = cfb.BVSMOD(dividend, divisor);
     CheckIsBvType(result, 4);
     var asLit = ExprUtil.AsLiteral(result);
     Assert.IsNotNull(asLit);
     CheckIsBvType(result, 4);
     Assert.IsTrue(ExprUtil.IsZero(result));
 }
Пример #24
0
            public static bool IsBasic(this BasicType type)
            {
                switch (type)
                {
                case BasicType.Class:
                case BasicType.Enum:
                    return(false);

                default:
                    return(true);
                }
            }
Пример #25
0
        private Sort GetBasicType(BasicType basicType)
        {
            if (!basicTypes.ContainsKey(basicType))
            {
                Sort typeAst = BuildBasicType(basicType);
                basicTypes.Add(basicType, typeAst);
            }
            Sort result;
            bool containsKey = basicTypes.TryGetValue(basicType, out result);

            Debug.Assert(containsKey);
            return(result);
        }
Пример #26
0
        public Load(string name, ExtensionType extensionType, BasicType basicType, object value)
        {

            this.name = name;
            
            if (extensionType != ExtensionType.List)
            {
                throw new Exception("Not supported type");
            }

            this.data = new List(basicType.ToString(), value);

        }
Пример #27
0
        public void MergeNotEqToCondition()
        {
            var builder   = GetConstantFoldingBuilder();
            var v         = GetVarAndIdExpr("group_size_y", BasicType.GetBvType(32)).Item2;
            var condition = builder.Eq(v, builder.ConstantBV(1, 32));
            var ite       = builder.IfThenElse(condition, builder.ConstantBV(1, 1), builder.ConstantBV(0, 1));

            Assert.IsNull(ExprUtil.AsLiteral(ite));
            var result = builder.NotEq(ite, builder.ConstantBV(0, 1));

            CheckIsBoolType(result);
            Assert.AreSame(condition, result);
        }
Пример #28
0
        public void MSBIsZero()
        {
            var cfb    = GetConstantFoldingBuilder();
            var msb    = cfb.ConstantBV(0, 8);
            var lsb    = GetVarAndIdExpr("x", BasicType.GetBvType(4)).Item2;
            var result = cfb.BVCONCAT(msb, lsb);

            var asBvZExt = ExprUtil.AsBVZEXT(result);

            Assert.IsNotNull(asBvZExt);
            CheckIsBvType(result, 12);
            Assert.AreSame(lsb, asBvZExt.Args[0]);
        }
Пример #29
0
        public void XorWithAllOnes()
        {
            var cfb     = GetConstantFoldingBuilder();
            var id      = GetVarAndIdExpr("x", BasicType.GetBvType(8)).Item2;
            var allOnes = cfb.ConstantBV(255, 8);
            var result  = cfb.BVXOR(id, allOnes);

            CheckIsBvType(result, 8);
            var resultAsBvNot = ExprUtil.AsBVNOT(result);

            Assert.IsNotNull(resultAsBvNot);
            Assert.AreSame(id, resultAsBvNot.Args[0]);
        }
Пример #30
0
        public static string GetExportType(this BasicType type, ExportLanguage language)
        {
            // Assumes MSVC++

            /*if(language == ExportLanguage.cpp)
             * {
             *  switch(type)
             *  {
             *      //case BasicType.
             *  }
             * }*/
            return("");
        }
Пример #31
0
            public void Array(BasicType type, string name, BasicExpression[] subs)
            {
                this.sb.Append(type.ToString()).Append("A(");

                this.sb.Append(name);

                foreach (BasicExpression sub in subs)
                {
                    this.sb.Append(", ");
                    sub.Accept(this);
                }

                this.sb.Append(")");
            }
        public void CreateFunctionCallExprWrongArgCount()
        {
            var FCB = GetFCBuilder();
            var SEB = GetSEBuilder();
            var fc  = FCB.CreateCachedUninterpretedFunctionCall("foo",
                                                                BasicType.Bool,
                                                                new List <Microsoft.Boogie.Type>()
            {
                BasicType.GetBvType(2),
                BasicType.GetBvType(2)
            });

            SEB.UFC(fc, SEB.ConstantBV(0, 3));
        }
Пример #33
0
        } // end constructor

        public DbgBaseTypeInfo(DbgEngDebugger debugger,
                               DbgModuleInfo module,
                               uint typeId,
                               BasicType baseType,
                               ulong size)
            : this(debugger,
                   GetModBase(module),
                   typeId,
                   baseType,
                   size,
                   module.Target)
        {
            __mod = module;
        } // end constructor
Пример #34
0
        static public object GetDefaultValue(this Type item)
        {
            BasicType type = item.GetBasicType();

            switch (type)
            {
            case BasicType.None: return(null);

            case BasicType.Void: return(null);

            case BasicType.Bool: return((bool)false);

            case BasicType.SByte: return((sbyte)0);

            case BasicType.Short: return((short)0);

            case BasicType.Int: return((int)0);

            case BasicType.Long: return((long)0);

            case BasicType.Byte: return((byte)0);

            case BasicType.UShort: return((ushort)0);

            case BasicType.UInt: return((uint)0);

            case BasicType.ULong: return((ulong)0);

            case BasicType.Float: return((float)0.0f);

            case BasicType.Double: return((double)0.0);

            case BasicType.Decimal: return((decimal)0.0m);

            case BasicType.Char: return((char)0);

            case BasicType.String: return((string)null);

            case BasicType.Array: return(null);

            case BasicType.Enum: return(item.GetEnumValueByLongValue(0));

            case BasicType.Struct: return(item.CreateInstance());

            case BasicType.Class: return(null);
            }

            throw new UnaccountedBranchException("type", type);
        }
Пример #35
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            BasicType basic_type = value_type.GetBasicType();

            switch (basic_type)
            {
            case BasicType.Bool: canvas.Emit_Ldc_I4(0); break;

            case BasicType.SByte: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Short: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Int: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Long: canvas.Emit_Ldc_I8(0); break;

            case BasicType.Byte: canvas.Emit_Ldc_U4(0); break;

            case BasicType.UShort: canvas.Emit_Ldc_U4(0); break;

            case BasicType.UInt: canvas.Emit_Ldc_U4(0); break;

            case BasicType.ULong: canvas.Emit_Ldc_U8(0); break;

            case BasicType.Float: canvas.Emit_Ldc_R4(0.0f); break;

            case BasicType.Double: canvas.Emit_Ldc_R8(0.0); break;

            case BasicType.Char: canvas.Emit_Ldc_I4(0); break;

            case BasicType.String: canvas.Emit_Ldstr(""); break;

            case BasicType.Array: canvas.Emit_Ldnull(); break;

            case BasicType.Enum: canvas.Emit_Ldc_I4(0); break;

            case BasicType.Class: canvas.Emit_Ldnull(); break;

            case BasicType.Struct:
                canvas.UseLocal(value_type, delegate(ILLocal local) {
                    local.RenderIL_LoadAddress(canvas);
                    canvas.Emit_Initobj(value_type);
                    local.RenderIL_Load(canvas);
                });
                break;

            default: throw new UnaccountedBranchException("basic_type", basic_type);
            }
        }
Пример #36
0
            public void Literal(BasicType type, object o)
            {
                this.sb.Append(type.ToString()).Append("L(");

                string s = o.ToString();

                if (type == BasicType.Str)
                {
                    s = "\"" + s + "\"";
                }

                this.sb.Append(s);

                this.sb.Append(")");
            }
Пример #37
0
            private static BasicExpression Type(BasicExpression x, BasicType expected)
            {
                if (x.Type != expected)
                {
                    string error = string.Format(
                        CultureInfo.InvariantCulture,
                        "Type mismatch; expected [{0}] to be of type {1} but was of type {2}.",
                        x,
                        expected,
                        x.Type);
                    throw new ParseException(error);
                }

                return(x);
            }
Пример #38
0
        public void simpleUF()
        {
            var builder = GetSimpleBuilder();
            var FCB     = new FunctionCallBuilder();
            var func    = FCB.CreateUninterpretedFunctionCall("foo", BasicType.Bool, new List <Microsoft.Boogie.Type>()
            {
                BasicType.Real,
                BasicType.Int,
                BasicType.GetBvType(8)
            });
            var root = builder.UFC(func, builder.ConstantReal("0.0"), builder.ConstantInt(5), builder.ConstantBV(5, 8));

            Assert.AreEqual("foo(0e0, 5, 5bv8)", root.ToString());
            DuplicateAndCheck(root, builder);
        }
Пример #39
0
 public override BasicType GetBasicType()
 {
     expr1Type = expr1.GetBasicType();
     expr2Type = expr2.GetBasicType();
     if ((expr1Type == BasicType.Boolean || expr1Type == BasicType.Number)
         && (expr2Type == BasicType.Boolean || expr2Type == BasicType.Number))
     {
         ourType = BasicType.Number;
     }
     else
     {
         ourType = BasicType.Error;
     }
     return ourType;
 }
Пример #40
0
        //Constructor for Max/Min
        public SimpleType(string name, BasicType basicType, decimal min, decimal max)
        {
            Name = name;
            _restriction = Restriction.MaxMin;
            _basicType = basicType;
            _max = max;
            _min = min;

            // Handle decimal not able to check number equality. (precision is not required)
            if (basicType == BasicType.Decimal)
            {
                _min = _min - (1 / 999999999999);
                _max = _max + (1 / 999999999999);
            }
        }
Пример #41
0
        public void NoFold()
        {
            var builderPair  = GetSimpleAndConstantFoldingBuilder();
            var sfb          = builderPair.Item1;
            var cfb          = builderPair.Item2;
            var v0           = GetVarAndIdExpr("x", BasicType.GetBvType(8));
            var v1           = GetVarAndIdExpr("y", BasicType.GetBvType(8));
            var foldedResult = cfb.BVLSHR(v0.Item2, v1.Item2);
            var simpleResult = sfb.BVLSHR(v0.Item2, v1.Item2);

            CheckIsBvType(foldedResult, 8);
            CheckIsBvType(simpleResult, 8);
            Assert.IsNotNull(ExprUtil.AsBVLSHR(foldedResult));
            Assert.AreEqual(simpleResult, foldedResult);
        }
Пример #42
0
 public void ShouldBeAbleToCacheBasicTypes()
 {
     BasicType original = new BasicType { Id = 123, Name = "abc" }, clone;
     using (var client = new MemcachedClient())
     {
         client.Store(StoreMode.Set, "ShouldBeAbleToCacheBasicTypes", original);
     }
     using (var client = new MemcachedClient())
     {
         clone = client.Get<BasicType>("ShouldBeAbleToCacheBasicTypes");
     }
     Assert.IsNotNull(clone);
     Assert.AreNotSame(original, clone);
     Assert.AreEqual(original.Id, clone.Id);
     Assert.AreEqual(original.Name, clone.Name);
 }
Пример #43
0
        public void Test()
        {
            byte a = 1;
            short b = 1;
            int c = -1;
            long d = 1;
            ushort e = 1;
            uint f = 1;
            ulong g = 1;
            float h = 1.1f;
            double i = 1.222;
            bool j = true;
            char k = 'a';
            string l = "aaa";
            DateTime m = new DateTime(2015,1,1,1,1,1);

            var encoder = new BasicType();
            Assert.IsTrue(BasicType.IsBasicType(a.GetType()));
            Assert.AreEqual(a, encoder.DeSerialize<byte>(encoder.Serialize(a)));
            Assert.IsTrue(BasicType.IsBasicType(b.GetType()));
            Assert.AreEqual(b, encoder.DeSerialize<short>(encoder.Serialize(b)));
            Assert.IsTrue(BasicType.IsBasicType(c.GetType()));
            Assert.AreEqual(c, encoder.DeSerialize<int>(encoder.Serialize(c)));
            Assert.IsTrue(BasicType.IsBasicType(d.GetType()));
            Assert.AreEqual(d, encoder.DeSerialize<long>(encoder.Serialize(d)));
            Assert.IsTrue(BasicType.IsBasicType(e.GetType()));
            Assert.AreEqual(e, encoder.DeSerialize<ushort>(encoder.Serialize(e)));
            Assert.IsTrue(BasicType.IsBasicType(f.GetType()));
            Assert.AreEqual(f, encoder.DeSerialize<uint>(encoder.Serialize(f)));
            Assert.IsTrue(BasicType.IsBasicType(g.GetType()));
            Assert.AreEqual(g, encoder.DeSerialize<ulong>(encoder.Serialize(g)));
            Assert.IsTrue(BasicType.IsBasicType(h.GetType()));
            Assert.AreEqual(h, encoder.DeSerialize<float>(encoder.Serialize(h)));
            Assert.IsTrue(BasicType.IsBasicType(i.GetType()));
            Assert.AreEqual(i, encoder.DeSerialize<double>(encoder.Serialize(i)));
            Assert.IsTrue(BasicType.IsBasicType(j.GetType()));
            Assert.AreEqual(j, encoder.DeSerialize<bool>(encoder.Serialize(j)));
            Assert.IsTrue(BasicType.IsBasicType(k.GetType()));
            Assert.AreEqual(k, encoder.DeSerialize<char>(encoder.Serialize(k)));
            Assert.IsTrue(BasicType.IsBasicType(l.GetType()));
            Assert.AreEqual(l, encoder.DeSerialize<string>(encoder.Serialize(l)));
            Assert.IsTrue(BasicType.IsBasicType(m.GetType()));
            Assert.AreEqual(m, encoder.DeSerialize<DateTime>(encoder.Serialize(m)));
            Assert.IsFalse(BasicType.IsBasicType(typeof(object)));
            Assert.Throws(typeof(ArgumentException), () => encoder.Serialize(new List<int>()));
        }
Пример #44
0
        public override void CheckTypes()
        {
            // Need to make sure that numericExpression is either
            // a number or a boolean
            expressionType = numericExpression.GetBasicType();

            // In this case we can't even allow Booleans which can only have
            // value of -1 or 0, neither of which is legal in an On-Goto
            if (expressionType != BasicType.Number)
            {
                throw new TypeCheckException("The expression used in a On-Goto statement must be numeric", line);
            }

            foreach (string target in targets)
            {
                if (!labels.ContainsKey(target))
                {
                    throw new TypeCheckException(
                        String.Format("Non existent line number {0} in On-Goto statement", target),
                        line);
                }
            }
        }
Пример #45
0
 public ValueDefinition(BasicType TypeOfValue, ADBBaseObject myValue)
 {
     Value = GraphDBTypeMapper.GetGraphObjectFromType(TypeOfValue, myValue.Value);
     IsDefined = true;
 }
Пример #46
0
 public override BasicType GetBasicType()
 {
     exprType = expr.GetBasicType();
     if (exprType == BasicType.Number || exprType == BasicType.Boolean) return BasicType.String;
     return BasicType.Error;
 }
Пример #47
0
 public MemberItem(TypeItem parent, Member metaData)
     : base(parent.Parent, metaData.Name) { Type = metaData.Type; }
Пример #48
0
	void TypeAtom(out Bpl.Type/*!*/ ty) {
		Contract.Ensures(Contract.ValueAtReturn(out ty) != null); ty = dummyType; 
		if (la.kind == 15) {
			Get();
			ty = new BasicType(t, SimpleType.Int); 
		} else if (la.kind == 16) {
			Get();
			ty = new BasicType(t, SimpleType.Real); 
		} else if (la.kind == 17) {
			Get();
			ty = new BasicType(t, SimpleType.Bool); 
		} else if (la.kind == 10) {
			Get();
			Type(out ty);
			Expect(11);
		} else SynErr(102);
	}
Пример #49
0
        /// <summary>
        /// Checks if the name of the attribute is valid for a certain GraphType.
        /// </summary>
        /// <param name="GraphTypeName">The GraphType.</param>
        /// <param name="myAttributeName">Name of the attribute.</param>
        /// <param name="typeOfAttributeValue">Kind of attribute value.</param>
        /// <param name="typeManager">The TypeManager of the GraphDB</param>
        /// <returns></returns>
        public static bool IsAValidAttributeType(GraphDBType aGraphType, BasicType typeOfAttributeValue, DBContext typeManager, Object myValue)
        {
            #region Data

            bool isValid = false;

            #endregion

            #region process types

            #region non-list type

            if (typeOfAttributeValue == BasicType.Unknown)
            {
                isValid = GraphDBTypeMapper.GetGraphObjectFromTypeName(aGraphType.Name).IsValidValue(myValue);
            }
            else
            {
                isValid = (GraphDBTypeMapper.ConvertGraph2CSharp(aGraphType.Name) == typeOfAttributeValue || aGraphType.IsUserDefined);
            }

            #endregion

            #endregion

            return isValid;
        }
Пример #50
0
        public static ADBBaseObject GetGraphObjectFromType(BasicType myTypeOfValue, Object myValue)
        {
            switch (myTypeOfValue)
            {

                case BasicType.Double:
                    if (myValue == null)
                        return new DBDouble();
                    else
                        return new DBDouble(myValue);

                case BasicType.UInt64:
                    if (myValue == null)
                        return new DBUInt64();
                    else
                        return new DBUInt64(myValue);

                case BasicType.Int64:
                    if (myValue == null)
                        return new DBInt64();
                    else
                        return new DBInt64(myValue);

                case BasicType.Int32:
                    if (myValue == null)
                        return new DBInt32();
                    else
                        return new DBInt32(myValue);

                case BasicType.String:
                    if (myValue == null)
                        return new DBString();
                    else
                        return new DBString(myValue);

                case BasicType.DateTime:
                    if (myValue == null)
                        return new DBDateTime();
                    else
                        return new DBDateTime(myValue);

                case BasicType.Boolean:
                    if (myValue == null)
                        return new DBBoolean();
                    else
                        return new DBBoolean(myValue);

                case BasicType.SetOfDBObjects:
                    if (myValue != null)
                        return new DBEdge(myValue);
                    return new DBEdge();

                case BasicType.Unknown:
                    if (myValue is String)
                        return new DBString(myValue);
                    return new DBNumber(myValue);

                case BasicType.NotABasicType:
                case BasicType.Reference:

                    if (myValue != null)
                    {

                        var _ADBBaseObject = myValue as ADBBaseObject;

                        if (_ADBBaseObject != null)
                            return _ADBBaseObject;

                        return new DBReference(myValue);

                    }

                    else
                    {

                        if (myTypeOfValue == BasicType.Reference)
                            return new DBReference();

                        return null;

                    }

                default:
                    throw new GraphDBException(new Error_TypeDoesNotExist(myTypeOfValue.ToString()));

            }
        }
Пример #51
0
 public static ADBBaseObject GetEmptyGraphObjectFromType(BasicType myTypeOfValue)
 {
     return GetGraphObjectFromType(myTypeOfValue, null);
 }
Пример #52
0
 public override Type VisitBasicType(BasicType node)
 {
     Contract.Ensures(Contract.Result<Type>() == node);
     return this.VisitType(node);
 }
Пример #53
0
 public virtual Type VisitBasicType(BasicType node) {
   Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<Type>() != null);
   return this.VisitType(node);
 }
Пример #54
0
 public Member(string name, BasicType type)
 {
     Name = name;
     Type = type;
 }
Пример #55
0
 public int GetBaseType(out BasicType baseType)
 {
     baseType = default(BasicType);
     int _baseType;
     int hr = S.StdCall<int>(GetVTableMember(43), Punk, out _baseType);
     GC.KeepAlive(this);
     baseType = (BasicType)_baseType;
     return hr;
 }
Пример #56
0
        public override void CheckTypes()
        {
            location.ConstrainType(symbols);
            BasicType locationType = location.BasicType;
            if (locationType != BasicType.String && locationType != BasicType.Number
                && locationType != BasicType.Boolean) throw new Exception("type error");

            if (builtIn != null)
            {
                switch (builtIn)
                {
                    case readExpr:
                        value = (locationType == BasicType.String) ?
                            BuiltInsMethodCall.ReadStringFromData() : BuiltInsMethodCall.ReadNumberFromData();
                        break;
                    case inputExpr:
                        value = (locationType == BasicType.String) ?
                            BuiltInsMethodCall.ReadStringFromConsole() : BuiltInsMethodCall.ReadNumberFromConsole();
                        break;
                }
            }

            valueType = value.GetBasicType();

            if (locationType == BasicType.String && valueType == BasicType.String) return;

            if (valueType == BasicType.Number || valueType == BasicType.Boolean) return;

            throw new Exception("Type mismatch exception in an assignment");
        }
Пример #57
0
 public override Type VisitBasicType(BasicType node) {
   //Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<Type>() != null);
   // do /not/ clone the type recursively
   return (BasicType)node.Clone();
 }
Пример #58
0
 public override BasicType GetBasicType()
 {
     BasicType t1 = e1.GetBasicType();
     BasicType t2 = e2.GetBasicType();
     if (t1 == t2)
     {
         argType = t1;
         return BasicType.Boolean;
     }
     return BasicType.Error;
 }
Пример #59
0
 protected static bool TypeIsNotNumeric(BasicType type)
 {
     if (type != BasicType.Number && type != BasicType.Boolean) return true;
     return false;
 }
Пример #60
0
        private static String ConvertBasicTypeToTypeString(BasicType basicType, long length, out bool isValueTypeOrByRef)
        {
            isValueTypeOrByRef = true;
            switch (basicType)
            {
                case BasicType.btNoType:
                    return "Unknown";

                case BasicType.btVoid:
                    return "Void";

                case BasicType.btChar:
                    return "Byte";

                case BasicType.btWChar:
                    return "Char";

                case BasicType.btInt:
                    if (length != 1L)
                    {
                        if (length == 2L)
                        {
                            return "Int16";
                        }
                        if ((length != 4L) && (length == 8L))
                        {
                            return "Int64";
                        }
                        return "Int32";
                    }
                    return "SByte";

                case BasicType.btUInt:
                    if (length != 1L)
                    {
                        if (length == 2L)
                        {
                            return "UInt16";
                        }
                        if ((length != 4L) && (length == 8L))
                        {
                            return "UInt64";
                        }
                        return "UInt32";
                    }
                    return "Byte";

                case BasicType.btFloat:
                    if (length != 8L)
                    {
                        return "Single";
                    }
                    return "Double";

                case BasicType.btBCD:
                    return "BCD";

                case BasicType.btBool:
                    return "Boolean";

                case BasicType.btLong:
                    return "Int64";

                case BasicType.btULong:
                    return "UInt64";

                case BasicType.btCurrency:
                    return "Currency";

                case BasicType.btDate:
                    return "Date";

                case BasicType.btVariant:
                    return "Variant";

                case BasicType.btComplex:
                    return "Complex";

                case BasicType.btBit:
                    return "Bit";

                case BasicType.btBSTR:
                    return "BSTR";

                case BasicType.btHresult:
                    return "Hresult";

                default:
                    return "?";
            }
        }