コード例 #1
0
 public void TypeMismatchAssignmentFromNumber_Test()
 {
     CmCompiler.CompileText(
         @"static bool b;
           b = 5;"
         );
 }
コード例 #2
0
 public void TypeMismatchDefinitionIndirectionLevel_Test2()
 {
     CmCompiler.CompileText(
         @"static int y = 0;
           static int* x = y;"
         );
 }
コード例 #3
0
 public void LargeReturnValuesNotSupportedTest()
 {
     CmCompiler.CompileText(
         @"typedef X { int x; int y; }
           X Test(int a);"
         );
 }
コード例 #4
0
 public void TypeMismatchDefinitionFromVariable_Test()
 {
     CmCompiler.CompileText(
         @"static bool b;
           static int x = b;"
         );
 }
コード例 #5
0
ファイル: ArrayErrorTests.cs プロジェクト: claassen/CmC
 public void ArrayIndexOnNonArray_Test2()
 {
     CmCompiler.CompileText(
         @"static int[10] x;
           (x[1])[2] = 1;"
         );
 }
コード例 #6
0
 public void ArrayAssignment_Test()
 {
     CmCompiler.CompileText(
         @"static int[10] x;
           x[1] = 1;"
         );
 }
コード例 #7
0
 public void ArrayToArrayAssignment_Test()
 {
     CmCompiler.CompileText(
         @"static int[10] x;
           static int[5] y = x;"
         );
 }
コード例 #8
0
 public void TypeMismatchDefinitionIndirectionLevel_Test3()
 {
     CmCompiler.CompileText(
         @"static int* x;
           static int y = *(*x);"
         );
 }
コード例 #9
0
ファイル: IndirectionLevelTests.cs プロジェクト: claassen/CmC
 public void IndirectionLevels_Test2()
 {
     CmCompiler.CompileText(
         @"static int** x;
           static int y = *(*x);"
         );
 }
コード例 #10
0
 public void TypeMismatchIndirectionLevel_Test4()
 {
     CmCompiler.CompileText(
         @"static int* x;
           static int* y = &x;"
         );
 }
コード例 #11
0
ファイル: TestBase.cs プロジェクト: claassen/CmC
        public TestVM ExecuteTestVM(string testCode)
        {
            CompilationContext context = CmCompiler.CompileText(testCode);

            byte[] objectCode;

            using (var s = new MemoryStream())
            {
                CmCompiler.CreateObjectCode(s, new RIVMArchitecture(), context.GetIR(), context.GetStringConstants(), context.GetGlobalVariables(), context.GetFunctions());
                objectCode = s.GetBuffer();
            }

            byte[] executableCode;

            using (var s = new MemoryStream())
            {
                CmLinker.Link(s, new List <byte[]> {
                    objectCode
                }, false, SystemMemoryMap.BIOS_ROM_START);
                executableCode = s.GetBuffer();
            }

            var bios = new BIOS(executableCode);

            var mmu = new MMU(SystemMemoryMap.BIOS_STACK_END, bios, null, null);

            var cpu = new CPU(mmu);

            cpu.Start();

            return(new TestVM(cpu));
        }
コード例 #12
0
ファイル: ArrayErrorTests.cs プロジェクト: claassen/CmC
 public void ArrayIndexOnNonArray_Test()
 {
     CmCompiler.CompileText(
         @"static int x;
           x[1] = 1;"
         );
 }
コード例 #13
0
ファイル: ArrayErrorTests.cs プロジェクト: claassen/CmC
 public void AssignmentToArrayVariable_Test()
 {
     CmCompiler.CompileText(
         @"static int[10] a;
           a = 1;"
         );
 }
コード例 #14
0
ファイル: VoidTypeTests.cs プロジェクト: claassen/CmC
 public void VoidAssignmentTo_Test()
 {
     CmCompiler.CompileText(
         @"static void a;
           static void b;
           a = b;"
         );
 }
コード例 #15
0
 public void AddressOfArrayIsSameAsArray_Test()
 {
     CmCompiler.CompileText(
         @"static int[10] x;
           static int* p = x;
           static int* q = &x;"
         );
 }
コード例 #16
0
 public void FunctionReturnTypeVoidMismatch_Test()
 {
     CmCompiler.CompileText(
         @"void Test() {
               return 0;
           }"
         );
 }
コード例 #17
0
 public void CompatibleTypeBoolean_Test3()
 {
     CmCompiler.CompileText(
         @"static bool a;
           static bool b;
           static bool res = a && b ^ 5;"
         );
 }
コード例 #18
0
ファイル: ArrayErrorTests.cs プロジェクト: claassen/CmC
 public void ArrayOfPointersAssignmentError_Test()
 {
     CmCompiler.CompileText(
         @"static int x; static int y;
           static int*[10] a;
           a[0] = x; a[1] = y;"
         );
 }
コード例 #19
0
 public void CompatibleTypeBoolean_Test5()
 {
     CmCompiler.CompileText(
         @"static int a;
           static int b;
           static bool res = a < 5 && b != 1;"
         );
 }
コード例 #20
0
 public void CompatibleTypeBoolean_Test4()
 {
     CmCompiler.CompileText(
         @"static bool a;
           static bool b;
           static bool res = 5 || a ^ b;"
         );
 }
コード例 #21
0
 public void TypeMismatchDefinitionFromExpression_Test()
 {
     CmCompiler.CompileText(
         @"static int x = 0;
           static int y = 1;
           static bool b = x + y;"
         );
 }
コード例 #22
0
 public void CompatibleTypeBoolean_Test2()
 {
     CmCompiler.CompileText(
         @"static int x = 0;
           static int y = 1;
           static bool res = x && y;"
         );
 }
コード例 #23
0
ファイル: ArrayErrorTests.cs プロジェクト: claassen/CmC
 public void PointerAsArrayAssignmentError_Test()
 {
     CmCompiler.CompileText(
         @"static int x; static int y;
           static int* a;
           a[0] = &x; a[1] = &y;"
         );
 }
コード例 #24
0
 public void UndefinedArgumentVariable_Test()
 {
     CmCompiler.CompileText(
         @"int Test(int x, int y) {
               return z;
           }"
         );
 }
コード例 #25
0
 public void FunctionReturnTypeMismatch_Test()
 {
     CmCompiler.CompileText(
         @"byte Test() {
               return (int)0;
           }"
         );
 }
コード例 #26
0
 public void TypeMismatchAssignmentFromVariable_Test()
 {
     CmCompiler.CompileText(
         @"static bool b;
           static int x = 0;
           x = b;"
         );
 }
コード例 #27
0
 public void MissingReturn_Test()
 {
     CmCompiler.CompileText(
         @"int Test(int x, int y, int z) {
               int temp = x + y;
           }"
         );
 }
コード例 #28
0
ファイル: IndirectionLevelTests.cs プロジェクト: claassen/CmC
 public void IndirectionLevels_Test()
 {
     CmCompiler.CompileText(
         @"static int x = 0;
           static int* y = &x;
           static int** z = &y;"
         );
 }
コード例 #29
0
 public void ArrayFunctionArgumentCalledWithPointer_Test()
 {
     CmCompiler.CompileText(
         @"int Test(int[] a) { return 0; }
           static int* a;
           Test(a);"
         );
 }
コード例 #30
0
 public void TypeMismatchIndirectionLevelAssignment_Test5()
 {
     CmCompiler.CompileText(
         @"static int* x;
           static int* y;
           y = &x;"
         );
 }