Exemplo n.º 1
0
 public TypeEnvironment(TypeEnvironment baseEnv)
 {
     this.m_typeEnv = new Dictionary <string, IValType>();
     foreach (var pair in baseEnv.m_typeEnv)
     {
         this.m_typeEnv.Add(pair.Key, pair.Value);
     }
 }
Exemplo n.º 2
0
        public CompileResult Typecheck(AST ast, Domain globDomain)
        {
            this.Bool  = globDomain.First <ValueType>("bool");
            this.Int32 = globDomain.First <ValueType>("int");

            TypeEnvironment tenv = new TypeEnvironment();

            foreach (ASTNode node in ast.Root)
            {
                var res = this.TypecheckNode(node, tenv, globDomain).Item1;
                if (!res)
                {
                    return(res);
                }
            }

            return(new CompileResult(true));
        }
Exemplo n.º 3
0
 private (CompileResult, IValType) TypecheckNode(ASTNode node, TypeEnvironment tenv, Domain domain) => node switch