Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increases reflection class limit to 1000 classes, from previous 250 #93

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/framework/Reflection.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,20 @@ function mr_getClass(name)
end if
end function

function mr_getClass2(name)
if false
end if
end function

function mr_getClass3(name)
if false
end if
end function

function mr_getClass4(name)
if false
end if
end function

function mr_getAllXMLCompNames(name)
end function
66 changes: 46 additions & 20 deletions src/lib/reflection/ReflectionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,55 @@ export default class ReflectionUtil {
}

public updateClassLookupFunction(file: BrsFile) {
let func = file.ast.statements[0] as FunctionStatement;
let that = this;
if (func?.func?.body?.statements.length > 0) {
let classNames = this.fileMap.classNames.filter((n: string) => {
let file = this.fileMap.getFileForClass(n);
if (!file) {
console.log('MISSING FILE for class:', n);
return false;
} else {
return that.shouldParseReflectionFile(file.bscFile);
}
}).map((n) => n.replace(/\./g, '_'));
let codeText = `if false
? "maestro reflection"`;
for (let name of classNames) {
codeText += `\n else if name = "${name}"
return ${name}`;
let classNames = this.fileMap.classNames.filter((n: string) => {
let file = this.fileMap.getFileForClass(n);
if (!file) {
console.log('MISSING FILE for class:', n);
return false;
} else {
return this.shouldParseReflectionFile(file.bscFile);
}
}).map((n) => n.replace(/\./g, '_'));

let funcIndex = 0;
const maxFuncs = 4;
for (let i = 0; i < Math.min(classNames.length, maxFuncs * 250); i += 250) {
let chunk = classNames.slice(i, i + 250);
let isLastFunction = (i + 250) >= classNames.length;
let codeText = this.generateFunctionBody(chunk, isLastFunction, funcIndex);

let func = file.ast.statements[funcIndex] as FunctionStatement;
if (func?.func?.body?.statements.length > 0) {
func.func.body.statements[funcIndex === 0 ? 1 : 0] = new RawCodeStatement(codeText);
} else {
console.error(`Function at index ${funcIndex} does not have the expected structure.`);
}
codeText += '\n end if';
func.func.body.statements[1] = new RawCodeStatement(codeText);

funcIndex++;
}
}

generateFunctionBody(classNames: string[], isLastFunction: boolean, index: number): string {
let codeText = `if false\n ? "maestro reflection"`;

for (let name of classNames) {
codeText += `\nelse if name = "${name}"\n return ${name}`;
}

if (!isLastFunction) {
let nextFunctionName = `mr_getClass${index + 2}`;
codeText += `\nelse\n return ${nextFunctionName}(name)`;
} else {
codeText += `\nelse\n return false`;
}

codeText += `\nend if`;

return codeText;
}

public updateXMLCompTypesFunction(file: BrsFile) {
let func = file.ast.statements[1] as FunctionStatement;
let func = file.ast.statements[4] as FunctionStatement;
if (func) {
let text = '{\n';

Expand Down Expand Up @@ -83,4 +107,6 @@ export default class ReflectionUtil {
}
return true;
}


}
Loading
Loading