Skip to content
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
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,12 @@
"ssh2": "^0.5.4"
},
"devDependencies": {
"typescript": "^2.1.6",
"vscode": "^1.0.3",
"mocha": "^3.2.0",
"@types/mocha": "^2.2.39",
"@types/node": "^7.0.5",
"@types/mocha": "^2.2.39"
"mocha": "^3.2.0",
"tslint": "^5.11.0",
"tslint-language-service": "^0.9.9",
"typescript": "^2.1.6",
"vscode": "^1.0.3"
}
}
2 changes: 1 addition & 1 deletion src/backend/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class VariableObject {
}

public toProtocolVariable(): DebugProtocol.Variable {
let res: DebugProtocol.Variable = {
const res: DebugProtocol.Variable = {
name: this.exp,
evaluateName: this.name,
value: (this.value === void 0) ? "<unknown>" : this.value,
Expand Down
35 changes: 17 additions & 18 deletions src/backend/gdb_expansion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const numberRegex = /^\d+(\.\d+)?/;
const pointerCombineChar = ".";

export function isExpandable(value: string): number {
let primitive: any;
let match;
value = value.trim();
if (value.length == 0) return 0;
Expand All @@ -31,13 +30,13 @@ export function isExpandable(value: string): number {
}

export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
let parseCString = () => {
const parseCString = () => {
value = value.trim();
if (value[0] != '"' && value[0] != '\'')
return "";
let stringEnd = 1;
let inString = true;
let charStr = value[0];
const charStr = value[0];
let remaining = value.substr(1);
let escaped = false;
while (inString) {
Expand All @@ -51,16 +50,16 @@ export function expandValue(variableCreate: Function, value: string, root: strin
remaining = remaining.substr(1);
stringEnd++;
}
let str = value.substr(0, stringEnd).trim();
const str = value.substr(0, stringEnd).trim();
value = value.substr(stringEnd).trim();
return str;
};

let stack = [root];
const stack = [root];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh this variable gets changed (in line 65)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const prevents of the variable from being reassigned, not the object they "point" to from being modified. In C++, it would be equivalent to this:

const Object *stack;

and not:

const Object * const stack;

let parseValue, parseCommaResult, parseCommaValue, parseResult, createValue;
let variable = "";

let getNamespace = (variable) => {
const getNamespace = (variable) => {
let namespace = "";
let prefix = "";
stack.push(variable);
Expand All @@ -86,11 +85,11 @@ export function expandValue(variableCreate: Function, value: string, root: strin
return prefix + namespace;
};

let parseTupleOrList = () => {
const parseTupleOrList = () => {
value = value.trim();
if (value[0] != '{')
return undefined;
let oldContent = value;
const oldContent = value;
value = value.substr(1).trim();
if (value[0] == '}') {
value = value.substr(1).trim();
Expand All @@ -103,19 +102,19 @@ export function expandValue(variableCreate: Function, value: string, root: strin
return <any>"<...>";
}
}
let eqPos = value.indexOf("=");
let newValPos1 = value.indexOf("{");
let newValPos2 = value.indexOf(",");
const eqPos = value.indexOf("=");
const newValPos1 = value.indexOf("{");
const newValPos2 = value.indexOf(",");
let newValPos = newValPos1;
if (newValPos2 != -1 && newValPos2 < newValPos1)
newValPos = newValPos2;
if (newValPos != -1 && eqPos > newValPos || eqPos == -1) { // is value list
let values = [];
const values = [];
stack.push("[0]");
let val = parseValue();
stack.pop();
values.push(createValue("[0]", val));
let remaining = value;
const remaining = value;
let i = 0;
while (true) {
stack.push("[" + (++i) + "]");
Expand All @@ -132,7 +131,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin

let result = parseResult(true);
if (result) {
let results = [];
const results = [];
results.push(result);
while (result = parseCommaResult(true))
results.push(result);
Expand All @@ -143,7 +142,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
return undefined;
};

let parsePrimitive = () => {
const parsePrimitive = () => {
let primitive: any;
let match;
value = value.trim();
Expand Down Expand Up @@ -208,14 +207,14 @@ export function expandValue(variableCreate: Function, value: string, root: strin

parseResult = (pushToStack: boolean = false) => {
value = value.trim();
let variableMatch = resultRegex.exec(value);
const variableMatch = resultRegex.exec(value);
if (!variableMatch)
return undefined;
value = value.substr(variableMatch[0].length).trim();
let name = variable = variableMatch[1];
const name = variable = variableMatch[1];
if (pushToStack)
stack.push(variable);
let val = parseValue();
const val = parseValue();
if (pushToStack)
stack.pop();
return createValue(name, val);
Expand Down
6 changes: 3 additions & 3 deletions src/backend/linux/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as fs from "fs"

export function spawnTerminalEmulator(preferedEmulator: string): Thenable<string> {
return new Promise((resolve, reject) => {
let ttyFileOutput = "/tmp/vscode-gdb-tty-0" + Math.floor(Math.random() * 100000000).toString(36);
const ttyFileOutput = "/tmp/vscode-gdb-tty-0" + Math.floor(Math.random() * 100000000).toString(36);
ChildProcess.spawn(preferedEmulator || "x-terminal-emulator", ["-e", "sh -c \"tty > " + ttyFileOutput + " && sleep 4294967294\""]);
let it = 0;
let interval = setInterval(() => {
const interval = setInterval(() => {
if (fs.existsSync(ttyFileOutput)) {
clearInterval(interval);
let tty = fs.readFileSync(ttyFileOutput).toString("utf8");
const tty = fs.readFileSync(ttyFileOutput).toString("utf8");
fs.unlink(ttyFileOutput);
return resolve(tty);
}
Expand Down
Loading