Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
Arquivo: Lambda.cs Projeto: plioi/rook
 public Expression WithTypes(TypeChecker visitor, Scope scope)
 {
     return(visitor.TypeCheck(this, scope));
 }