Example #1
0
        private ILanguageExpression CompileMacroCall(GMacMacro macro, OperandsByValueAccess operands)
        {
            PushRecord(macro.ChildScope, false);

            foreach (var param in macro.Parameters)
            {
                CompileVariable(param);

                //Set the initial values of all parameters of called macro to their default
                var defaultAssignmentCommand =
                    new OperandsByValueAccessAssignment(
                        LanguageValueAccess.Create(param),
                        GMacRootAst.CreateDefaultValue(param.SymbolType)
                        );

                CompileParameterAssignment(defaultAssignmentCommand);
            }

            foreach (var command in operands.AssignmentsList)
            {
                CompileParameterAssignment(command);
            }

            //this.Visit(macro.ProcedureBody);
            Visit(macro.OptimizedCompiledBody);

            var compiledOutputVariable = GetSymbolData(macro.OutputParameter);

            PopRecord();

            return(LanguageValueAccess.Create(compiledOutputVariable));
        }
        public TreeNode Visit(OperandsByValueAccessAssignment assignment)
        {
            var node = new TreeNode("<OP_ASSIGN> " + assignment.LhsValueAccess.GetName())
            {
                Tag = assignment
            };

            node.Nodes.Add(assignment.RhsExpression.AcceptVisitor(this));

            return(node);
        }
Example #3
0
        /// <summary>
        /// Assign values to parameters or structure members
        /// </summary>
        /// <param name="assignment"></param>
        /// <returns></returns>
        public ILanguageValue Visit(OperandsByValueAccessAssignment assignment)
        {
            var topAr = ActiveAr;

            ActiveAr = ActiveAr.UpperDynamicAr;

            var rhsValue = assignment.RhsExpression.AcceptVisitor(this);

            ActiveAr = topAr;

            //TODO: Is it necessary to make a copy of the RHS value in all cases?

            UpdateSymbolValue(assignment.LhsValueAccess, rhsValue.DuplicateValue(true));

            return(null);
        }
Example #4
0
        internal void CompileParameterAssignment(OperandsByValueAccessAssignment assignment)
        {
            //Compile the parameter in the active activation record
            var compiledLhsValue = CompileLhsValueAccess(assignment.LhsValueAccess);

            //Compile the rhs expression in the upper dynamic activation record
            var topAr = ActiveAr;

            ActiveAr = ActiveAr.UpperDynamicAr;

            var compiledRhsExpr = CompileExpression(assignment.RhsExpression);

            ActiveAr = topAr;

            _compiledBlock.AddCommand_Assign(compiledLhsValue, compiledRhsExpr);
        }
Example #5
0
        public void Visit(OperandsByValueAccessAssignment command)
        {
            Log.AppendAtNewLine("param assign ");

            command.LhsValueAccess.AcceptVisitor(this);

            Log.Append(" : ");

            Log.Append(command.LhsValueAccess.ExpressionType.TypeSignature);

            Log.Append(" = ");

            command.RhsExpression.AcceptVisitor(this);

            Log.AppendAtNewLine();
        }