/// <summary> /// Adds an IRapEntry to entry collection based on Type. /// </summary> /// <param name="entry">Entry to be added.</param> /// <param name="reader">Reader for reading binarized rap entry.</param> public void AddEntry(IRapEntry entry, RapBinaryReader reader) { if (entry is RapClass) { Classes.Add(reader.ReadBinarizedRapEntry <RapClass>()); } if (entry is RapExtern) { Externs.Add(reader.ReadBinarizedRapEntry <RapExtern>()); } if (entry is RapDelete) { Deletes.Add(reader.ReadBinarizedRapEntry <RapDelete>()); } if (entry is RapValue) { Values.Add(reader.ReadBinarizedRapEntry <RapValue>()); } if (entry is RapArray) { Arrays.Add(reader.ReadBinarizedRapEntry <RapArray>()); } }
private IEnumerable <ProcedureCompilation> CompileDeclaration(IDeclaration declaration) { switch (declaration) { case NamespaceDeclaration decl: foreach (var compilation in decl.Declarations.SelectMany(CompileDeclaration)) { yield return(compilation); } break; case Procedure procedure: var(transformed, parameters) = Transformer.TransformProcedureStatement(procedure.EntryPoint, procedure.Parameters); var cfg = CFGNode.ConstructCFG(transformed); LivenessAnalysis.PerformAnalysis(cfg); var allocation = RegisterAllocation.Generate(cfg, parameters .Select((x, i) => (x, i)).Where(x => x.i != 1).ToDictionary( x => x.x, x => ProcedureCompilation.ParameterLocation(x.i))); yield return(new ProcedureCompilation(procedure, parameters, transformed, ConstantTable, FalseConstant, TrueConstant, allocation)); break; case ProcedureImport import: Externs.Add(import.Name); Imports.Add(import.ImportedName); break; } }
public RichGenerationContext AddExtern(ExternAliasDirectiveSyntax externAliasDirective) { Externs.Add(externAliasDirective); return(this); }