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

Why makeValueString has noArray option for multidimensional arrays? #159

Open
alexandruionascu opened this issue Jan 27, 2024 · 0 comments

Comments

@alexandruionascu
Copy link
Contributor

In rt.ts I'm noticing this option for transforming a variable into a string.
For arrays in 2D, 3D, etc. the returned value would be [[...], [...], [...]].
Is there any reason this line cannot be commented out?
I ran the tests again and I don't see any breaking changes.
This will help me to debug multi-dimensional arrays.

Thank you!

    makeValueString(l: Variable | DummyVariable, options?: MakeValueStringOptions): string {
        let display: string;
        if (!options) { options = {}; }
        if (this.isPrimitiveType(l)) {
            if (this.isTypeEqualTo(l.t, this.charTypeLiteral)) {
                display = "'" + String.fromCharCode(l.v as number) + "'";
            } else if (this.isBoolType(l.t)) {
                display = l.v !== 0 ? "true" : "false";
            } else {
                display = l.v.toString();
            }
        } else if (this.isPointerType(l)) {
            if (this.isFunctionType(l.t)) {
                display = "<function>";
            } else if (this.isArrayType(l)) {
                if (this.isTypeEqualTo(l.t.eleType, this.charTypeLiteral)) {
                    // string
                    display = "\"" + this.getStringFromCharArray(l) + "\"";
                } else if (options.noArray) {
                    display = "[...]";
                } else {
                    //options.noArray = true;
                    const displayList = [];
                    for (let i = l.v.position, end = l.v.target.length, asc = l.v.position <= end; asc ? i < end : i > end; asc ? i++ : i--) {
                        displayList.push(this.makeValueString(l.v.target[i], options));
                    }
                    display = "[" + displayList.join(",") + "]";
                }
            } 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant