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); } }
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); }
public void ExitOperator(string operatorText, bool twoArg = true) { var instruction = AssemblyBuilderHelpers.GetInstructionForOperator(operatorText, twoArg); _activeContext.SetEndInstruction(instruction); }