Example #1
0
        public Function TypeCheck(Function function, Scope scope)
        {
            var position       = function.Position;
            var returnTypeName = function.ReturnTypeName;
            var name           = function.Name;
            var parameters     = function.Parameters;
            var body           = function.Body;

            var typedParameters = GetTypedParameters(parameters).ToVector();

            var localScope = CreateLocalScope(scope, typedParameters);

            var typedBody = (Block)TypeCheck(body, localScope);

            var returnType = TypeOf(returnTypeName);

            Unify(typedBody.Position, returnType, typedBody.Type);

            return(new Function(position, returnTypeName, name, typedParameters, typedBody, typeRegistry.DeclaredType(function)));
        }
Example #2
0
 public NamedType(Class @class, TypeRegistry typeRegistry)
     : this(@class.Name.Identifier)
 {
     methods = @class.Methods.Select(m => (Binding)new MethodBinding(m.Name.Identifier, typeRegistry.DeclaredType(m))).ToArray();
 }