Example #1
0
        public TypeSpec Verify()
        {
            FuncState.PushFunc(ReturnType);
            VarTab.PushScope();
            Params.ForEach(par => VarTab.Add(par.Id, par.Type));
            Stmts.ForEach(stmt => stmt.Verify());
            VarTab.PopScope();
            FuncState.PopFunc();

            Params.ForEach(par => par.Verify());
            if (Params.Select(x => x.Id).ToList().Count != Params.Select(x => x.Id).ToHashSet().Count)
            {
                throw new ArgumentException();
            }

            return(new TypeSpec
            {
                Base = new Function
                {
                    ReturnType = ReturnType,
                    Types = Params
                }
            });
        }