-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Type, string> 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(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/Assignment.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Line 7, Column 4: Cannot assign float to int | ||
Line 8, Column 4: Cannot assign void to int |
4 changes: 2 additions & 2 deletions
4
...etalConstructionToolTests/Snapshots/TypeCheckerTests/CreateAgentTypeMismatch.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Line 10, Column 11: Cannot convert float to int | ||
Line 11, Column 11: Cannot convert float to int |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FloatToInt.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Line 2, Column 4: Cannot assign float to int | ||
Line 3, Column 4: Cannot assign float to int |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/FunctionArguments.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
Line 6, Column 4: Cannot convert float to int in call expression. | ||
Line 7, Column 4: Cannot convert float to int in call expression. |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/PredTypeMismatch.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
Line 5, Column 15: Cannot convert float to int in predicate. | ||
Line 7, Column 15: Cannot convert float to int in predicate. |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/TypecastMismatch.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Line 4, Column 8: Cannot typecast from int to void. | ||
Line 4, Column 4: Cannot assign void to float |
4 changes: 2 additions & 2 deletions
4
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/VoidVariable.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Line 2, Column 3: Variable cannot be of type: void | ||
Line 2, Column 3: Cannot assign int to void |
2 changes: 1 addition & 1 deletion
2
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongArgumentType.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Line 4, Column 4: Cannot convert System.Int32 to System.Void in call expression. | ||
Line 4, Column 4: Cannot convert int to void in call expression. |
2 changes: 1 addition & 1 deletion
2
SocietalConstructionToolTests/Snapshots/TypeCheckerTests/WrongReturnType.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
Line 2, Column 4: Cannot convert the returned type to the function's expected return type, expected expression of type void, got int. |