Example #1
0
        private ILanguageExpressionAtomic CompileRhsValueAccess(LanguageValueAccess valueAccess)
        {
            var compiledRootSymbol = valueAccess.RootSymbol;

            //Replace a reference to a constant by its value
            var namedValue = compiledRootSymbol as SymbolNamedValue;

            if (namedValue != null)
            {
                var compiledFullValue = namedValue.AssociatedValue;

                return
                    (valueAccess.IsFullAccess
                    ? compiledFullValue.DuplicateValue(true)
                    : ValueAccessProcessor.ReadPartialValue(compiledFullValue, valueAccess).DuplicateValue(true));
            }

            if (compiledRootSymbol is SymbolLocalVariable || compiledRootSymbol is SymbolProcedureParameter)
            {
                compiledRootSymbol = GetSymbolData((SymbolDataStore)compiledRootSymbol);
            }

            var compiledValueAccess = LanguageValueAccess.Create(compiledRootSymbol);

            if (valueAccess.IsPartialAccess)
            {
                //Note: This will not be correct for components of class ValueAccessStepBySymbol
                //because the component symbol must be compiled too. But GMac doesn't use these components anyway
                compiledValueAccess.Append(valueAccess.PartialAccessSteps);
            }

            return(compiledValueAccess);
        }
Example #2
0
        /// <summary>
        /// Read the value associated with a value access process
        /// </summary>
        /// <param name="valueAccess"></param>
        /// <returns></returns>
        public virtual ILanguageValue Visit(LanguageValueAccess valueAccess)
        {
            var value = ReadSymbolFullValue(valueAccess.RootSymbol);

            return
                (valueAccess.IsFullAccess ?
                 value :
                 ValueAccessProcessor.ReadPartialValue(value, valueAccess));
        }