コード例 #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));
        }
コード例 #2
0
 static IntObj()
 {
     for (int i = 0; i < 384; i++)
     {
         smallIntObjs[i] = new IntObj(i - 128);
     }
 }
コード例 #3
0
        //public Transform parentToMoveInstead;

        private void Reset()
        {
            if (intObj == null)
            {
                intObj = GetComponent <IntObj>();
            }
        }
コード例 #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]);
            }
        }
コード例 #5
0
ファイル: IntColumnUpdater.cs プロジェクト: cell-lang/csharp
        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));
        }
コード例 #6
0
ファイル: parser.cs プロジェクト: cell-lang/csharp-old
        ////////////////////////////////////////////////////////////////////////////////

        // 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
            }
        }
コード例 #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();
     }
 }
コード例 #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));
        }
コード例 #9
0
ファイル: IntStoreUpdater.cs プロジェクト: cell-lang/csharp
 // 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)));
 }
コード例 #10
0
ファイル: conversions.cs プロジェクト: cell-lang/csharp-old
        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)));
        }
コード例 #11
0
ファイル: procs.cs プロジェクト: cell-lang/csharp-old
        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));
            }
        }
コード例 #12
0
        protected override void OnEnable()
        {
            base.OnEnable();

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

            if (intObj != null)
            {
                intObj.OnGraspBegin += onGraspBegin;
                intObj.OnGraspEnd   += onGraspEnd;
            }
        }
コード例 #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)));
        }
コード例 #14
0
ファイル: parser.cs プロジェクト: cell-lang/csharp-old
        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)));
            }
        }
コード例 #15
0
ファイル: NeIntSeqObj.cs プロジェクト: cell-lang/csharp
 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);
 }
コード例 #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");
        }
コード例 #17
0
ファイル: SeqObj.cs プロジェクト: cell-lang/csharp
 public override NeSeqObj Append(long value)
 {
     return(Append(IntObj.Get(value)));
 }
コード例 #18
0
    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);
        }
    }
コード例 #19
0
ファイル: NeIntSeqObj.cs プロジェクト: cell-lang/csharp
 public override Obj GetObjAt(long idx)
 {
     return(IntObj.Get(GetLongAt(idx)));
 }
コード例 #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));
        }
コード例 #21
0
ファイル: ColumnBase.cs プロジェクト: cell-lang/csharp
        //////////////////////////////////////////////////////////////////////////////

        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));
        }
コード例 #22
0
 public override uint Hashcode()
 {
     return(Hashing.Hashcode(SymbObj.Get(GetTagId()).Hashcode(), IntObj.Hashcode(GetInnerLong())));
 }
コード例 #23
0
 public void Animate(IntObj a, IntObj b, AnimateFlag flag)
 {
 }
コード例 #24
0
ファイル: value.cs プロジェクト: cell-lang/csharp-old
 override public Obj AsObj()
 {
     return(IntObj.Get(value));
 }
コード例 #25
0
 public void Animate(IntObj a, IntObj b, AnimateFlag flag)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public override Obj GetInnerObj()
 {
     return(IntObj.Get(GetInnerLong()));
 }