public override Type Check(TypeCheckingEnvironment env, FunctionEnvironment fEnv) { Type t1 = e1.Check(env, fEnv); env.DeclareLocal(name, t1); Type t2 = e2.Check(env, fEnv); env.Pop(); return(t2); }
public void Check(TypeCheckingEnvironment typeCheckingEnvironment, FunctionEnvironment functionEnvironment) { typeCheckingEnvironment.DeclareLocal(_argument.Item1, _argument.Item2); var t = _body.Check(typeCheckingEnvironment, functionEnvironment); typeCheckingEnvironment.Pop(); if (t != _returnType) { throw new InvalidOperationException(string.Format("Body of {0} returns {1}, {2} expected", _name, t, _returnType)); } }
public void Check(TypeCheckingEnvironment env, FunctionEnvironment fEnv) { foreach (var arg in args) { env.DeclareLocal(arg.Item1, arg.Item2); } Type t = body.Check(env, fEnv); foreach (var arg in args) { env.Pop(); } if (t != returnType) { throw new InvalidOperationException("Body of " + fName + " returns " + t + ", " + returnType + " expected"); } }