Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a type checking rule for the Main Machine #790

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Plang.Compiler.TypeChecker.AST;
using Plang.Compiler.TypeChecker.AST.Declarations;
using Plang.Compiler.TypeChecker.AST.ModuleExprs;
using Plang.Compiler.TypeChecker.Types;

namespace Plang.Compiler.TypeChecker
{
Expand Down Expand Up @@ -189,13 +190,21 @@ internal void CheckSafetyTest(SafetyTest test)
$"test module is not closed with respect to created interfaces; interface {@interface.First().Name} is created but not implemented inside the module");
}

//check that the test module main machine exists
// check that the test module main machine exists
var hasMainMachine = test.ModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec);
if (!hasMainMachine)
{
throw handler.NoMain(test.SourceLocation,
$"machine {test.Main} does not exist in the test module");
}

// make sure that the main machine does not take a parameter as input
globalScope.Get(test.Main, out Machine main);
if (!main.PayloadType.Equals(PrimitiveType.Null))
{
throw handler.NoMain(test.SourceLocation,
$"main machine {test.Main} cannot take an input parameter in the start state entry function.");
}
}

internal void CheckImplementationDecl(Implementation impl)
Expand Down
Loading