public static Trapl.Core.Session FailWithCode(this Trapl.Core.Session session, Trapl.Diagnostics.MessageCode code) { if (session.HasInternalErrors()) Assert.Inconclusive("Internal compiler error."); Assert.IsTrue(session.HasErrors(), "Compilation encountered no errors, but some were expected."); Assert.IsTrue(session.HasMessagesWithCode(code), "No errors of the specified code were encountered."); return session; }
public static Trapl.Core.Type ResolveType(Trapl.Core.Session session, string typeName) { var input = Trapl.Core.TextInput.MakeFromString(typeName); var tokens = Trapl.Grammar.Tokenizer.Tokenize(session, input); var astParser = new Trapl.Grammar.ASTParser(session, tokens); var typeNode = astParser.ParseType(); var type = Trapl.Semantics.TypeResolver.Resolve(session, typeNode, null, false); if (type.IsError()) Assert.Inconclusive("Type resolve error."); return type; }