felixhao28/JSCPP

Why makeValueString has noArray option for multidimensional arrays?

Opened this issue · 0 comments

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(",") + "]";
                }
            }