-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#72) CodeGen: support unsigned char type
- Loading branch information
Showing
7 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
Cesium.CodeGen.Tests/CodeGenMethodTests.PrimitiveTypes.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
System.Int32 <Module>::main() | ||
Locals: | ||
System.Byte V_0 | ||
System.Int32 V_1 | ||
System.Byte V_2 | ||
IL_0000: ldc.i4 0 | ||
IL_0005: ret |
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Cesium.CodeGen.Ir.Declarations; | ||
using Cesium.CodeGen.Ir.Types; | ||
using Cesium.Parser; | ||
using Yoakke.SynKit.C.Syntax; | ||
|
||
namespace Cesium.CodeGen.Tests; | ||
|
||
public class CodeGenPrimitiveTypeTests | ||
{ | ||
[Theory] | ||
[InlineData("char", PrimitiveTypeKind.Char)] | ||
[InlineData("int", PrimitiveTypeKind.Int)] | ||
[InlineData("void", PrimitiveTypeKind.Void)] | ||
[InlineData("unsigned char", PrimitiveTypeKind.UnsignedChar)] | ||
internal void Test(string typeString, PrimitiveTypeKind expectedKind) | ||
{ | ||
var source = $"{typeString} x;"; | ||
var parser = new CParser(new CLexer(source)); | ||
var ast = parser.ParseDeclaration().Ok.Value; | ||
var declarationInfo = (ScopedIdentifierDeclaration)IScopedDeclarationInfo.Of(ast); | ||
var item = declarationInfo.Items.Single(); | ||
var type = (PrimitiveType)item.Declaration.Type; | ||
Assert.Equal(expectedKind, type.Kind); | ||
} | ||
} |
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
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
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
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