Beispiel #1
0
 public override Type Check(TEnv env, FEnv fenv)
 {
     foreach (var expression in expressions)
     {
         Type    argType = expression.Check(env, fenv);
         FuncDef fDef    = fenv.getFunction(fName);
         if (!fDef.CheckArgType(argType))
         {
             throw new TypeException("Type error in call of function " + fName);
         }
     }
     return(Type.intType);
 }
Beispiel #2
0
        public override int Eval(REnv env, FEnv fenv)
        {
            int        value  = 0;
            List <int> values = new List <int>();

            foreach (var expression in expressions)
            {
                int argValue = expression.Eval(env, fenv);
                values.Add(argValue);
            }
            FuncDef fDef = fenv.getFunction(fName);

            value = fDef.Eval(env, fenv, values);
            return(value);
        }
        public override Type Check(TEnv env, FEnv fenv)
        {
            Type[] types = new Type[args.Count];
            int    index = 0;

            foreach (Expression arg in args)
            {
                types[index++] = arg.Check(env, fenv);
            }
            FuncDef fDef = fenv.getFunction(fName);

            if (fDef.CheckArgTypes(types))
            {
                return(fDef.returnType);
            }
            else
            {
                throw new TypeException("Type error in call of function " + fName);
            }
        }
        public override int Eval(REnv env, FEnv fenv)
        {
            int[] argValues;

            if (args.Count > 0)
            {
                int index = 0;
                argValues = new int[args.Count];
                foreach (Expression arg in args)
                {
                    argValues[index++] = arg.Eval(env, fenv);
                }
            }
            else
            {
                argValues = new int[0];
            }
            FuncDef fDef = fenv.getFunction(fName);

            return(fDef.Eval(env, fenv, argValues));
        }