Ejemplo n.º 1
0
        private ForeignKeyViolationException ForeignKeyViolation(int keySurr)
        {
            Obj key = source.store.SurrToValue(keySurr);

            Obj[] fromTuple = new Obj[] { key, IntObj.Get(source.Lookup(keySurr)) };
            return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, fromTuple, key));
        }
Ejemplo n.º 2
0
 static IntObj()
 {
     for (int i = 0; i < 384; i++)
     {
         smallIntObjs[i] = new IntObj(i - 128);
     }
 }
Ejemplo n.º 3
0
        //public Transform parentToMoveInstead;

        private void Reset()
        {
            if (intObj == null)
            {
                intObj = GetComponent <IntObj>();
            }
        }
Ejemplo n.º 4
0
        public override void Copy(int first, int count, Obj[] array, int destOffset)
        {
            int srcOffset = offset + first;

            for (int i = 0; i < count; i++)
            {
                array[destOffset + i] = IntObj.Get(ints[srcOffset + i]);
            }
        }
Ejemplo n.º 5
0
        private KeyViolationException Col1KeyViolation(int idx, long value, long otherValue, bool betweenNew)
        {
            //## BUG: Stores may contain only part of the value (id(5) -> 5)
            Obj key = store.SurrToValue(idx);

            Obj[] tuple1 = new Obj[] { key, IntObj.Get(value) };
            Obj[] tuple2 = new Obj[] { key, IntObj.Get(otherValue) };
            return(new KeyViolationException(relvarName, KeyViolationException.key_1, tuple1, tuple2, betweenNew));
        }
Ejemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////////

        // If the function is successfull, it returns the index of the next token to consume
        // If it fails, it returns the location/index of the error, negated and decremented by one
        static long ParseObj(Token[] tokens, long offset, out Obj var)
        {
            int length = tokens.Length;

            if (offset >= length)
            {
                var = null;
                return(-offset - 1);
            }

            Token token = tokens[offset];

            switch (token.type)
            {
            case TokenType.Comma:
            case TokenType.Colon:
            case TokenType.Semicolon:
            case TokenType.Arrow:
            case TokenType.ClosePar:
            case TokenType.CloseBracket:
                var = null;
                return(-offset - 1);

            case TokenType.Int:
                var = IntObj.Get((long)token.value);
                return(offset + 1);

            case TokenType.Float:
                var = new FloatObj((double)token.value);
                return(offset + 1);

            case TokenType.Symbol:
                return(ParseSymbOrTaggedObj(tokens, offset, out var));

            case TokenType.OpenPar:
                if (IsRecord(tokens, offset))
                {
                    return(ParseRec(tokens, offset, out var));
                }
                else
                {
                    return(ParseSeq(tokens, offset, out var));
                }

            case TokenType.OpenBracket:
                return(ParseUnordColl(tokens, offset, out var));

            case TokenType.String:
                var = Miscellanea.StrToObj((string)token.value);
                return(offset + 1);

            default:
                var = null;
                throw new InvalidOperationException(); // Unreachable code
            }
        }
Ejemplo n.º 7
0
 public static Obj At(long[] array, int size, long idx)
 {
     if (idx < size)
     {
         return(IntObj.Get(array[(int)idx]));
     }
     else
     {
         throw ErrorHandler.SoftFail();
     }
 }
Ejemplo n.º 8
0
        public static Obj BuildConstIntSeq(int[] vals)
        {
            int len = vals.Length;

            Obj[] objs = new Obj[len];
            for (int i = 0; i < len; i++)
            {
                objs[i] = IntObj.Get(vals[i]);
            }
            return(new MasterSeqObj(objs));
        }
Ejemplo n.º 9
0
 // Inefficient, but used only for debugging
 public override Obj SurrToValue(int surr)
 {
     for (int i = 0; i < count; i++)
     {
         if (surrogates[i] == surr)
         {
             return(IntObj.Get(values[i]));
         }
     }
     return(IntObj.Get(store.SurrToValue(surr)));
 }
Ejemplo n.º 10
0
        public static Obj StringToObj(string str)
        {
            int[] cps = Miscellanea.CodePoints(str);
            int   len = cps.Length;

            Obj[] objs = new Obj[len];
            for (int i = 0; i < len; i++)
            {
                objs[i] = IntObj.Get(cps[i]);
            }
            return(new TaggedObj(SymbTable.StringSymbId, new MasterSeqObj(objs)));
        }
Ejemplo n.º 11
0
        public static Obj GetChar_P(object env)
        {
            int ch = Console.Read();

            if (ch != -1)
            {
                return(new TaggedObj(SymbTable.JustSymbId, IntObj.Get(ch)));
            }
            else
            {
                return(SymbObj.Get(SymbTable.NothingSymbId));
            }
        }
Ejemplo n.º 12
0
        protected override void OnEnable()
        {
            base.OnEnable();

            if (intObj == null)
            {
                intObj = GetComponent <IntObj>();
            }

            if (intObj != null)
            {
                intObj.OnGraspBegin += onGraspBegin;
                intObj.OnGraspEnd   += onGraspEnd;
            }
        }
Ejemplo n.º 13
0
        public static Obj StrToObj(string str)
        {
            int len = str.Length;

            Obj[] chars = new Obj[len];
            int   count = 0;
            int   i     = 0;

            while (i < len)
            {
                int ch = Char.ConvertToUtf32(str, i);
                chars[count++] = IntObj.Get(ch);
                i += Char.IsSurrogatePair(str, i) ? 2 : 1;
            }
            return(new TaggedObj(SymbTable.StringSymbId, new MasterSeqObj(chars, count)));
        }
Ejemplo n.º 14
0
        public static Obj Parse(Obj text)
        {
            byte[] bytes = text.GetInnerObj().GetByteArray();
            Obj    obj;
            long   errorOffset;
            bool   ok = Parse(bytes, out obj, out errorOffset);

            if (ok)
            {
                return(new TaggedObj(SymbTable.SuccessSymbId, obj));
            }
            else
            {
                return(new TaggedObj(SymbTable.FailureSymbId, IntObj.Get(errorOffset)));
            }
        }
Ejemplo n.º 15
0
 public override uint Hashcode()
 {
     if (hcode == Hashing.NULL_HASHCODE)
     {
         long code = 0;
         int  len  = GetSize();
         for (int i = 0; i < len; i++)
         {
             code = 31 * code + IntObj.Hashcode(GetLongAt(i));
         }
         hcode = Hashing.Hashcode64(code);
         if (hcode == Hashing.NULL_HASHCODE)
         {
             hcode++;
         }
     }
     return(hcode);
 }
Ejemplo n.º 16
0
        public string CastActor(IntObj o)
        {
            string connectionString =
                @"Data Source=rpsdb.cgluvdnfm6uc.us-east-1.rds.amazonaws.com; 
            Initial Catalog=Movies;
            User ID=admin;
            Password=password";

            SqlConnection con = new SqlConnection(connectionString);

            string     queryString = "insert into casting (castid, actorno, movieno) values (@id, @aNum, @mNum)";
            SqlCommand command     = new SqlCommand(queryString, con);

            command.Parameters.AddWithValue("@id", (int)o.ioId);
            command.Parameters.AddWithValue("@aNum", (int)o.ioAnum);
            command.Parameters.AddWithValue("@mNum", (int)o.ioMnum);


            con.Open();
            var result = command.ExecuteNonQuery();

            return(result.ToString() + " rows updated in Casting table in Movies.sql");
        }
Ejemplo n.º 17
0
 public override NeSeqObj Append(long value)
 {
     return(Append(IntObj.Get(value)));
 }
    static void Run(int length, int repeat, bool report)
    {
        var data = new object[length];

        int chk   = 0;
        var watch = Stopwatch.StartNew();

        for (int j = 0; j < repeat; j++)
        {
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = i;
                chk    += i;
            }
        }
        watch.Stop();
        if (report)
        {
            Console.WriteLine("Box: {0}ms (chk: {1})", watch.ElapsedMilliseconds, chk);
        }
        chk   = 0;
        watch = Stopwatch.StartNew();
        for (int j = 0; j < repeat; j++)
        {
            for (int i = 0; i < data.Length; i++)
            {
                chk += (int)data[i];
            }
        }
        watch.Stop();
        if (report)
        {
            Console.WriteLine("Unbox: {0}ms (chk: {1})", watch.ElapsedMilliseconds, chk);
        }

        chk   = 0;
        watch = Stopwatch.StartNew();
        for (int j = 0; j < repeat; j++)
        {
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = new IntObj(i);
                chk    += i;
            }
        }
        watch.Stop();
        if (report)
        {
            Console.WriteLine("Wrap: {0}ms (chk: {1})", watch.ElapsedMilliseconds, chk);
        }
        chk   = 0;
        watch = Stopwatch.StartNew();
        for (int j = 0; j < repeat; j++)
        {
            for (int i = 0; i < data.Length; i++)
            {
                chk += ((IntObj)data[i]).Value;
            }
        }
        watch.Stop();
        if (report)
        {
            Console.WriteLine("Unwrap: {0}ms (chk: {1})", watch.ElapsedMilliseconds, chk);
        }
    }
Ejemplo n.º 19
0
 public override Obj GetObjAt(long idx)
 {
     return(IntObj.Get(GetLongAt(idx)));
 }
Ejemplo n.º 20
0
        //////////////////////////////////////////////////////////////////////////////

        private ForeignKeyViolationException ForeignKeyViolation(int keySurr, long value)
        {
            Obj[] tuple = new Obj[] { source.store.SurrToValue(keySurr), IntObj.Get(value) };
            return(ForeignKeyViolationException.BinaryUnary(source.relvarName, 1, target.relvarName, tuple));
        }
Ejemplo n.º 21
0
        //////////////////////////////////////////////////////////////////////////////

        public static Obj Copy(ColumnBase[] columns, bool flipCols)
        {
            int totalSize = 0;

            for (int i = 0; i < columns.Length; i++)
            {
                totalSize += columns[i].count;
            }

            if (totalSize == 0)
            {
                return(EmptyRelObj.singleton);
            }

            Obj[] objs1 = new Obj[totalSize];
            Obj[] objs2 = new Obj[totalSize];

            int next = 0;

            for (int i = 0; i < columns.Length; i++)
            {
                ColumnBase col = columns[i];
                if (col is IntColumn)
                {
                    IntColumn      intCol = (IntColumn)col;
                    IntColumn.Iter it     = intCol.GetIter();
                    while (!it.Done())
                    {
                        objs1[next] = intCol.mapper(it.GetIdx());
                        objs2[next] = IntObj.Get(it.GetValue());
                        next++;
                        it.Next();
                    }
                }
                else if (col is FloatColumn)
                {
                    FloatColumn      floatCol = (FloatColumn)col;
                    FloatColumn.Iter it       = floatCol.GetIter();
                    while (!it.Done())
                    {
                        objs1[next] = floatCol.mapper(it.GetIdx());
                        objs2[next] = new FloatObj(it.GetValue());
                        next++;
                        it.Next();
                    }
                }
                else
                {
                    ObjColumn      objCol = (ObjColumn)col;
                    ObjColumn.Iter it     = objCol.GetIter();
                    while (!it.Done())
                    {
                        objs1[next] = objCol.mapper(it.GetIdx());
                        objs2[next] = it.GetValue();
                        next++;
                        it.Next();
                    }
                }
            }
            Debug.Assert(next == totalSize);

            if (flipCols)
            {
                Obj[] tmp = objs1;
                objs1 = objs2;
                objs2 = tmp;
            }

            return(Builder.CreateBinRel(objs1, objs2));
        }
Ejemplo n.º 22
0
 public override uint Hashcode()
 {
     return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), IntObj.Hashcode(GetInnerLong())));
 }
 public void Animate(IntObj a, IntObj b, AnimateFlag flag)
 {
 }
Ejemplo n.º 24
0
 override public Obj AsObj()
 {
     return(IntObj.Get(value));
 }
 public void Animate(IntObj a, IntObj b, AnimateFlag flag)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 26
0
 public override Obj GetInnerObj()
 {
     return(IntObj.Get(GetInnerLong()));
 }