From 1891119393108f5002afb8a1698e63d4332cf2e2 Mon Sep 17 00:00:00 2001 From: Jet8100 Date: Mon, 15 Apr 2024 10:36:28 +0200 Subject: [PATCH] changed system.type to type --- SocietalConstructionTool/Compiler/SctType.cs | 16 +++++++++++++++- .../TypeCheckerTests/Assignment.verified.txt | 4 ++-- .../CreateAgentTypeMismatch.verified.txt | 4 ++-- .../TypeCheckerTests/FloatToInt.verified.txt | 4 ++-- .../FunctionArguments.verified.txt | 4 ++-- .../PredTypeMismatch.verified.txt | 4 ++-- .../TypecastMismatch.verified.txt | 4 ++-- .../TypeCheckerTests/VoidVariable.verified.txt | 4 ++-- .../WrongArgumentType.verified.txt | 2 +- .../WrongReturnType.verified.txt | 2 +- 10 files changed, 31 insertions(+), 17 deletions(-) diff --git a/SocietalConstructionTool/Compiler/SctType.cs b/SocietalConstructionTool/Compiler/SctType.cs index 971a7b99..2c1a6896 100644 --- a/SocietalConstructionTool/Compiler/SctType.cs +++ b/SocietalConstructionTool/Compiler/SctType.cs @@ -1,7 +1,21 @@ +using System.CommandLine.IO; + +using Microsoft.CodeAnalysis.CSharp.Syntax; + namespace Sct.Compiler { public class SctType(Type targetType) { - public Type TargetType { get; } = targetType; + + private static readonly Dictionary Types = new() + { + { typeof(int), "int" }, + { typeof(double), "float" }, + { typeof(void) , "void" }, + }; + + public string TargetType { get; } = Types[targetType]; + + private void Type(Type targetType) => throw new NotImplementedException(); } } diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/Assignment.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/Assignment.verified.txt index 92207caa..269dfae4 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/Assignment.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/Assignment.verified.txt @@ -1,2 +1,2 @@ -Line 7, Column 4: Cannot assign System.Double to System.Int32 -Line 8, Column 4: Cannot assign System.Void to System.Int32 \ No newline at end of file +Line 7, Column 4: Cannot assign float to int +Line 8, Column 4: Cannot assign void to int \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/CreateAgentTypeMismatch.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/CreateAgentTypeMismatch.verified.txt index 5ffb3f7c..01fddec4 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/CreateAgentTypeMismatch.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/CreateAgentTypeMismatch.verified.txt @@ -1,2 +1,2 @@ -Line 10, Column 11: Cannot convert System.Double to System.Int32 -Line 11, Column 11: Cannot convert System.Double to System.Int32 \ No newline at end of file +Line 10, Column 11: Cannot convert float to int +Line 11, Column 11: Cannot convert float to int \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FloatToInt.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FloatToInt.verified.txt index 94a2093e..d35e3d86 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FloatToInt.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FloatToInt.verified.txt @@ -1,2 +1,2 @@ -Line 2, Column 4: Cannot assign System.Double to System.Int32 -Line 3, Column 4: Cannot assign System.Double to System.Int32 \ No newline at end of file +Line 2, Column 4: Cannot assign float to int +Line 3, Column 4: Cannot assign float to int \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FunctionArguments.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FunctionArguments.verified.txt index d3395561..ab4575dd 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FunctionArguments.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FunctionArguments.verified.txt @@ -1,2 +1,2 @@ -Line 6, Column 4: Cannot convert System.Double to System.Int32 in call expression. -Line 7, Column 4: Cannot convert System.Double to System.Int32 in call expression. \ No newline at end of file +Line 6, Column 4: Cannot convert float to int in call expression. +Line 7, Column 4: Cannot convert float to int in call expression. \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/PredTypeMismatch.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/PredTypeMismatch.verified.txt index e444496c..88f22bdb 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/PredTypeMismatch.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/PredTypeMismatch.verified.txt @@ -1,2 +1,2 @@ -Line 5, Column 15: Cannot convert System.Double to System.Int32 in predicate. -Line 7, Column 15: Cannot convert System.Double to System.Int32 in predicate. \ No newline at end of file +Line 5, Column 15: Cannot convert float to int in predicate. +Line 7, Column 15: Cannot convert float to int in predicate. \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/TypecastMismatch.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/TypecastMismatch.verified.txt index b1f9b1b1..e3f1bda8 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/TypecastMismatch.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/TypecastMismatch.verified.txt @@ -1,2 +1,2 @@ -Line 4, Column 8: Cannot typecast from System.Int32 to System.Void. -Line 4, Column 4: Cannot assign System.Void to System.Double \ No newline at end of file +Line 4, Column 8: Cannot typecast from int to void. +Line 4, Column 4: Cannot assign void to float \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/VoidVariable.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/VoidVariable.verified.txt index 57cde050..df4c827e 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/VoidVariable.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/VoidVariable.verified.txt @@ -1,2 +1,2 @@ -Line 2, Column 3: Variable cannot be of type: System.Void -Line 2, Column 3: Cannot assign System.Int32 to System.Void \ No newline at end of file +Line 2, Column 3: Variable cannot be of type: void +Line 2, Column 3: Cannot assign int to void \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongArgumentType.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongArgumentType.verified.txt index 7706bfec..5a8eb470 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongArgumentType.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongArgumentType.verified.txt @@ -1 +1 @@ -Line 4, Column 4: Cannot convert System.Int32 to System.Void in call expression. \ No newline at end of file +Line 4, Column 4: Cannot convert int to void in call expression. \ No newline at end of file diff --git a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongReturnType.verified.txt b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongReturnType.verified.txt index 8dd38a45..09440202 100644 --- a/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongReturnType.verified.txt +++ b/SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongReturnType.verified.txt @@ -1 +1 @@ -Line 2, Column 4: Cannot convert the returned type to the function's expected return type, expected expression of type System.Void, got System.Int32. \ No newline at end of file +Line 2, Column 4: Cannot convert the returned type to the function's expected return type, expected expression of type void, got int. \ No newline at end of file