コード例 #1
0
ファイル: String.cs プロジェクト: zrbruce/FlingOS
        public Testing2.String Substring(int startIndex, int aLength)
        {
            if (startIndex >= this.length)
            {
                if (aLength == 0)
                {
                    return(New(0));
                }
                UART.Write("IndexOutOfRangeException! Substring.");
                //ExceptionMethods.Throw(new Exceptions.IndexOutOfRangeException(startIndex, this.length));
            }
            else if (aLength > length - startIndex)
            {
                aLength = length - startIndex;
            }

            Testing2.String result = New(aLength);
            for (int i = startIndex; i < aLength + startIndex; i++)
            {
                result[i - startIndex] = this[i];
            }
            return(result);
        }
コード例 #2
0
        public static unsafe void Clear()
        {
            if (!Initialised)
            {
                return;
            }
            //Clear out every character on the screen
            int numToClear = rows * cols;

            //Start at beginning of video memory
            //char* vidMemPtr = vidMemBasePtr;
            //Loop through all video memory
            while (numToClear > 0)
            {
                //Set output to no character, no foreground colour, just the
                //  background colour.
                UART.Write(' ');
                //And decrement the count
                numToClear--;
            }

            WriteLine();
        }
コード例 #3
0
 public void aMethodVoid()
 {
     UART.Write("Class method void right\n");
 }
コード例 #4
0
ファイル: GC.cs プロジェクト: zrbruce/FlingOS
        public static void *NewArr(int length, Testing2.Type elemType)
        {
            if (!Enabled)
            {
                BasicConsole.SetTextColour(BasicConsole.warning_colour);
                BasicConsole.WriteLine("Warning! GC returning null pointer because GC not enabled.");
                BasicConsole.DelayOutput(10);
                BasicConsole.SetTextColour(BasicConsole.default_colour);

                return(null);
            }

            //try
            {
                if (length < 0)
                {
                    UART.Write("length < 0. Overflow exception.");
                    return(null);
                    //ExceptionMethods.Throw_OverflowException();
                }

                InsideGC = true;

                //Alloc space for GC header that prefixes object data
                //Alloc space for new array object
                //Alloc space for new array elems

                uint totalSize = ((Testing2.Type) typeof(Testing2.Array)).Size;
                if (elemType.IsValueType)
                {
                    totalSize += elemType.Size * (uint)length;
                }
                else
                {
                    totalSize += elemType.StackSize * (uint)length;
                }
                totalSize += (uint)sizeof(GCHeader);

                GCHeader *newObjPtr = (GCHeader *)Heap.AllocZeroed(totalSize, "GC : NewArray");

                if ((UInt32)newObjPtr == 0)
                {
                    InsideGC = false;

                    BasicConsole.SetTextColour(BasicConsole.error_colour);
                    BasicConsole.WriteLine("Error! GC can't create a new array because the heap returned a null pointer.");
                    BasicConsole.DelayOutput(10);
                    BasicConsole.SetTextColour(BasicConsole.default_colour);

                    return(null);
                }

                NumObjs++;

                //Initialise the GCHeader
                SetSignature(newObjPtr);
                newObjPtr->RefCount = 1;

                Testing2.Array newArr = (Testing2.Array)Utilities.ObjectUtilities.GetObject(newObjPtr + 1);
                newArr._Type    = (Testing2.Type) typeof(Testing2.Array);
                newArr.length   = length;
                newArr.elemType = elemType;

                //Move past GCHeader
                byte *newObjBytePtr = (byte *)(newObjPtr + 1);

                InsideGC = false;

                return(newObjBytePtr);
            }
            //finally
            {
            }
        }