示例#1
0
        public override void ExitParameterList(DaedalusParser.ParameterListContext context)
        {
            var parameterDeclContexts = context.parameterDecl();

            foreach (var parameterDeclContext in parameterDeclContexts.Reverse())
            {
                BaseExecBlockContext baseExecBlock = _assemblyBuilder.ExecBlocks.Last();
                string    execBlockName            = baseExecBlock.GetSymbol().Name;
                string    parameterLocalName       = parameterDeclContext.nameNode().GetText();
                string    parameterName            = $"{execBlockName}.{parameterLocalName}";
                DatSymbol parameterSymbol          = _assemblyBuilder.ResolveSymbol(parameterName);

                var assignInstruction =
                    AssemblyBuilderHelpers.GetAssignInstructionForDatSymbolType(parameterSymbol.Type);

                if (parameterSymbol.Type is DatSymbolType.Instance)
                {
                    _assemblyBuilder.AddInstruction(new PushInstance(parameterSymbol));
                }
                else
                {
                    _assemblyBuilder.AddInstruction(new PushVar(parameterSymbol));
                }

                _assemblyBuilder.AddInstruction(assignInstruction);
            }
        }