Пример #1
0
        //Adds a provided variable to the current scope or modifies an existing
        //variable with the same name (this is required because match variables unlike
        //regular variables in the same scope can shadow each other).
        private int AddMatchVariable(string varName, ElaExpression exp, out bool newV)
        {
            var sv = ScopeVar.Empty;

            newV = false;

            //Here we first check if such a name is already added and if this is the case simply fetch an
            //existing name.
            if (CurrentScope.Parent != null && CurrentScope.Parent.Locals.TryGetValue(varName, out sv) &&
                (sv.Flags & ElaVariableFlags.Parameter) == ElaVariableFlags.Parameter)
            {
                return(0 | sv.Address << 8);
            }
            else
            {
                var res = CurrentScope.TryChangeVariable(varName);
                newV = true;

                if (res != -1)
                {
                    return(0 | res << 8);
                }

                return(AddVariable(varName, exp, ElaVariableFlags.None, -1));
            }
        }