public CompilerResult Build(CompilationUnit compilationUnit) { var typeChecker = new TypeChecker(); var typedCompilationUnit = typeChecker.TypeCheck(compilationUnit); if (typeChecker.HasErrors) return new CompilerResult(Language.Rook, typeChecker.Errors); string translatedCode = Translate(typedCompilationUnit); return csCompiler.Build(translatedCode); }
private CompilerResult Build(CompilationUnit compilationUnit, out string translation) { translation = ""; var typeChecker = new TypeChecker(); var typedCompilationUnit = typeChecker.TypeCheck(compilationUnit); if (typeChecker.HasErrors) return new CompilerResult(Language.Rook, typeChecker.Errors); translation = Translate(typedCompilationUnit); return csCompiler.Build(translation); }
public void HasATypeInWhichOnlyGenericTypeVariablesAreFreshenedOnEachScopeLookup() { using (TypeVariable.TestFactory()) { //Prevent type '1' from being freshened on type lookup by marking it as non-generic: var typeVariable0 = TypeVariable.CreateGeneric(); var typeVariable1 = TypeVariable.CreateNonGeneric(); var expectedTypeAfterLookup = new NamedType("A", new TypeVariable(4), typeVariable1, new NamedType("B", new TypeVariable(4), typeVariable1)); var definedType = new NamedType("A", typeVariable0, typeVariable1, new NamedType("B", typeVariable0, typeVariable1)); var typeChecker = new TypeChecker(); var globalScope = new GlobalScope(); var localScope = new LocalScope(globalScope); localScope.Bind("foo", definedType); Type("foo", localScope, typeChecker).ShouldEqual(expectedTypeAfterLookup); } }
public Expression WithTypes(TypeChecker visitor, Scope scope) { return(visitor.TypeCheck(this, scope)); }