public TES5CodeChunkCollection createCodeChunk(ITES4CodeChunk chunk, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4Branch branch = chunk as TES4Branch; if (branch != null) { return(TES5BranchFactory.CreateCodeChunk(branch, codeScope, globalScope, multipleScriptsScope, this, valueFactory)); } TES4Return returnChunk = chunk as TES4Return; if (returnChunk != null) { return(this.returnFactory.CreateCodeChunkCollection(codeScope.LocalScope.FunctionScope, globalScope, multipleScriptsScope)); } ITES4Callable callable = chunk as ITES4Callable; if (callable != null) { return(this.valueFactory.CreateCodeChunks(callable, codeScope, globalScope, multipleScriptsScope)); } TES4VariableAssignation assignation = chunk as TES4VariableAssignation; if (assignation != null) { return(this.variableAssignationConversionFactory.CreateCodeChunk(assignation, codeScope, globalScope, multipleScriptsScope)); } TES4VariableDeclarationList declarationList = chunk as TES4VariableDeclarationList; if (declarationList != null) { TES5LocalVariableListFactory.createCodeChunk(declarationList, codeScope); return(null); } throw new ConversionException("Cannot convert a chunk: " + chunk.GetType().FullName); }
public static TES5CodeChunkCollection CreateCodeChunk(TES4Branch chunk, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope, TES5ChainedCodeChunkFactory codeChunkFactory, TES5ValueFactory valueFactory) { TES5SubBranch mainBranch = ConvertSubBranch(chunk.MainBranch, codeScope, globalScope, multipleScriptsScope, codeChunkFactory, valueFactory); TES4SubBranchList branchList = chunk.ElseifBranches; TES5SubBranchList convertedElseIfBranches = null; if (branchList != null) { convertedElseIfBranches = new TES5SubBranchList(); foreach (TES4SubBranch subBranch in branchList.Branches) { convertedElseIfBranches.Add(ConvertSubBranch(subBranch, codeScope, globalScope, multipleScriptsScope, codeChunkFactory, valueFactory)); } } TES4ElseSubBranch elseBranch = chunk.ElseBranch; TES5ElseSubBranch convertedElseBranch = null; if (elseBranch != null) { convertedElseBranch = ConvertElseBranch(elseBranch, codeScope, globalScope, multipleScriptsScope, codeChunkFactory); } return(new TES5CodeChunkCollection() { new TES5Branch(mainBranch, convertedElseIfBranches, convertedElseBranch) }); }