Ejemplo n.º 1
0
        private ILanguageValue EvaluateBasicPolyadicMacroCall(GMacMacro macro, OperandsByValueAccess operands)
        {
            PushRecord(macro.ChildScope, false);

            //Initialize parameters to their default values
            foreach (var param in macro.Parameters)
            {
                var paramValue = GMacRootAst.CreateDefaultValue(param.SymbolType);

                ActiveAr.AddSymbolData(param, paramValue);
            }

            //Modify assigned parameters values from macro call operands
            foreach (var command in operands.AssignmentsList)
            {
                Visit(command);
            }

            //Execute macro body
            macro.SymbolBody.AcceptVisitor(this);
            //macro.OptimizedCompiledBody.AcceptVisitor(this);

            //Read output parameter value
            var value = ActiveAr.GetSymbolData(macro.FirstOutputParameter);

            PopRecord();

            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute a variable declaration command
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public override ILanguageValue Visit(CommandDeclareVariable command)
        {
            var symbolValue = GMacRootAst.CreateDefaultValue(command.DataStore.SymbolType);

            ActiveAr.AddSymbolData(command.DataStore, symbolValue);

            return(null);
        }
Ejemplo n.º 3
0
        private SymbolLocalVariable CompileVariable(SymbolDataStore variable)
        {
            var varName = "CV" + (_tempVariableIndex++).ToString("X4");

            var declareCommand = _compiledBlock.DefineLocalVariable(varName, variable.SymbolType);

            var compiledVariable = (SymbolLocalVariable)declareCommand.DataStore;

            ActiveAr.AddSymbolData(variable, compiledVariable);

            return(compiledVariable);
        }