Пример #1
0
        public Value Invoke(params Value[] values)
        {
            if (values.Length != parameters.Length)
                throw new Exception("Wrong number of values for parameters.");

            for (int i = 0; i < values.Length && i < parameters.Length; i++)
            {
                Parameter p = parameters[i];
                Value v = values[i];

                if (p.GetVariableType() != v.GetVariableType())
                {
                    throw new Exception("Parameter " + p.GetName() + " should be " + p.GetVariableType() + ". Got " + v.GetVariableType());
                }

                AddVariable(new Variable(this, p.GetVariableType(), p.GetName(), v.GetValue()));
            }

            foreach(Block b in GetSubBlocks())
            {
                b.Execute();

                if (returnValue != null)
                    break;
            }

            if (returnValue == null && returnType != "void")
                throw new Exception("No return value");

            Value localReturnValue = returnValue;
            returnValue = null;
            return localReturnValue;
        }
Пример #2
0
 public void SetReturnValue(Value value)
 {
     returnValue = value;
 }