Пример #1
0
        public int GetVariableIndex(string variable)
        {
            var index = Arguments.IndexOf(Arguments.SingleOrDefault(arg => arg.Name == variable));

            if (index != -1)
            {
                return(1 + index);                // 1 is reserved for this
            }

            index = Locals.IndexOf(Locals.SingleOrDefault(local => local.Name == variable));
            if (index != -1)
            {
                return(1 + Arguments.Count + index);                // 1 is reserved for this and locals are after arguments
            }

            throw new Exception(string.Format("Variable with name {0} not found!", variable));
        }