コード例 #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);
            }
        }
コード例 #2
0
        public void AssignmentEnd(string assignmentOperator)
        {
            //TODO check if there are any possibilities of assignmentLeftSide longer than 2 instructions?
            var operationType         = _assignmentLeftSide.Last().Symbol.Type;
            var assignmentInstruction =
                AssemblyBuilderHelpers.GetInstructionForOperator(assignmentOperator, true, operationType);

            if (!IsInsideConstDef)
            {
                AddInstructions(new List <AssemblyElement>(_assignmentLeftSide));
            }
            _assignmentLeftSide = new List <SymbolInstruction>();
            AddInstruction(assignmentInstruction);
        }
コード例 #3
0
        public void ExitOperator(string operatorText, bool twoArg = true)
        {
            var instruction = AssemblyBuilderHelpers.GetInstructionForOperator(operatorText, twoArg);

            _activeContext.SetEndInstruction(instruction);
        }