yann300
10 years ago
21 changed files with 996 additions and 1001 deletions
@ -1,35 +1,97 @@ |
|||
import QtQuick 2.2 |
|||
import QtQuick.Controls 1.1 |
|||
import "js/ErrorLocationFormater.js" as ErrorLocationFormater |
|||
|
|||
Rectangle { |
|||
id: constantCompilationStatus |
|||
objectName: "constantCompilationStatus" |
|||
function update() |
|||
{ |
|||
if (constantCompilation.result.successfull) |
|||
{ |
|||
image.state = ""; |
|||
status.state = ""; |
|||
status.text = qsTr("Compile without errors."); |
|||
logslink.visible = false; |
|||
} |
|||
else |
|||
{ |
|||
image.state = "error"; |
|||
status.state = "error"; |
|||
var errorInfo = ErrorLocationFormater.extractErrorInfo(constantCompilation.result.compilerMessage, true); |
|||
status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail; |
|||
logslink.visible = true; |
|||
} |
|||
} |
|||
|
|||
anchors.fill: parent |
|||
width: parent.width |
|||
height: parent.height |
|||
color: "lightgray" |
|||
Text { |
|||
font.pointSize: 9 |
|||
anchors.left: parent.left |
|||
anchors.top: parent.top |
|||
anchors.topMargin: 3 |
|||
anchors.leftMargin: 3 |
|||
height: 9 |
|||
font.family: "Monospace" |
|||
objectName: "status" |
|||
id: status |
|||
gradient: Gradient { |
|||
GradientStop { position: 0.0; color: "#f1f1f1" } |
|||
GradientStop { position: 1.0; color: "#d9d7da" } |
|||
} |
|||
TextArea { |
|||
readOnly: true |
|||
anchors.left: parent.left |
|||
anchors.leftMargin: 10 |
|||
anchors.top: status.bottom |
|||
anchors.topMargin: 3 |
|||
font.pointSize: 9 |
|||
font.family: "Monospace" |
|||
height: parent.height * 0.8 |
|||
width: parent.width - 20 |
|||
wrapMode: Text.Wrap |
|||
backgroundVisible: false |
|||
objectName: "content" |
|||
id: content |
|||
Rectangle { |
|||
anchors.horizontalCenter: parent.horizontalCenter |
|||
anchors.verticalCenter: parent.verticalCenter |
|||
anchors.topMargin: 10 |
|||
anchors.bottomMargin: 10 |
|||
radius: 3 |
|||
width: 500 |
|||
height: 30 |
|||
color: "#fffcd5" |
|||
Row { |
|||
anchors.horizontalCenter: parent.horizontalCenter |
|||
anchors.verticalCenter: parent.verticalCenter |
|||
spacing: 5 |
|||
Image |
|||
{ |
|||
source: "qrc:/qml/img/compilsuceeded.png" |
|||
id: image |
|||
states:[ |
|||
State { |
|||
name: "error" |
|||
PropertyChanges { |
|||
target: image |
|||
source: "qrc:/qml/img/compilfailed.png" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
|
|||
Text { |
|||
font.pointSize: 10 |
|||
height: 9 |
|||
font.family: "sans serif" |
|||
objectName: "status" |
|||
id: status |
|||
states:[ |
|||
State { |
|||
name: "error" |
|||
PropertyChanges { |
|||
target: status |
|||
color: "red" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
|
|||
Text { |
|||
|
|||
visible: false |
|||
font.pointSize: 9 |
|||
height: 9 |
|||
text: qsTr("See log.") |
|||
font.family: "Monospace" |
|||
objectName: "status" |
|||
id: logslink |
|||
color: "#8c8a74" |
|||
MouseArea { |
|||
anchors.fill: parent |
|||
onClicked: { |
|||
mainContent.ensureRightView(); |
|||
debugModel.debugDeployment(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
@ -1,181 +1,27 @@ |
|||
//humanReadableExecutionCode => contain human readable code.
|
|||
//debugStates => contain all debug states.
|
|||
//bytesCodeMapping => mapping between humanReadableExecutionCode and bytesCode.
|
|||
//statesList => ListView
|
|||
|
|||
var currentSelectedState = null; |
|||
var jumpStartingPoint = null; |
|||
function init() |
|||
{ |
|||
statesSlider.maximumValue = debugStates.length - 1; |
|||
statesList.model = humanReadableExecutionCode; |
|||
currentSelectedState = 0; |
|||
select(currentSelectedState); |
|||
//displayReturnValue();
|
|||
|
|||
jumpoutbackaction.state = "disabled"; |
|||
jumpintobackaction.state = "disabled"; |
|||
jumpintoforwardaction.state = "disabled" |
|||
jumpoutforwardaction.state = "disabled" |
|||
|
|||
} |
|||
|
|||
function moveSelection(incr) |
|||
{ |
|||
if (currentSelectedState + incr >= 0) |
|||
{ |
|||
if (currentSelectedState + incr < debugStates.length) |
|||
{ |
|||
select(currentSelectedState + incr); |
|||
} |
|||
else |
|||
{ |
|||
//endOfDebug();
|
|||
} |
|||
statesSlider.value = currentSelectedState; |
|||
} |
|||
} |
|||
|
|||
function select(stateIndex) |
|||
{ |
|||
var codeLine = codeStr(stateIndex); |
|||
var state = debugStates[stateIndex]; |
|||
highlightSelection(codeLine); |
|||
currentSelectedState = stateIndex; |
|||
completeCtxInformation(state); |
|||
//levelList.model = state.levels;
|
|||
//levelList.update();
|
|||
|
|||
if (state.instruction === "JUMP") |
|||
jumpintoforwardaction.state = ""; |
|||
else |
|||
jumpintoforwardaction.state = "disabled"; |
|||
|
|||
if (state.instruction === "JUMPDEST") |
|||
jumpintobackaction.state = ""; |
|||
else |
|||
jumpintobackaction.state = "disabled"; |
|||
} |
|||
|
|||
function codeStr(stateIndex) |
|||
{ |
|||
var state = debugStates[stateIndex]; |
|||
return bytesCodeMapping.getValue(state.curPC); |
|||
} |
|||
|
|||
function highlightSelection(index) |
|||
{ |
|||
statesList.currentIndex = index; |
|||
} |
|||
|
|||
function completeCtxInformation(state) |
|||
{ |
|||
basicInfo.currentStep = state.step; |
|||
basicInfo.mem = state.newMemSize + " " + qsTr("words"); |
|||
basicInfo.stepCost = state.gasCost; |
|||
basicInfo.gasSpent = debugStates[0].gas - state.gas; |
|||
// This is available in all editors.
|
|||
stack.listModel = state.debugStack; |
|||
storage.listModel = state.debugStorage; |
|||
memoryDump.listModel = state.debugMemory; |
|||
callDataDump.listModel = state.debugCallData; |
|||
} |
|||
|
|||
function endOfDebug() |
|||
function formatLocation(raw, shortMessage) |
|||
{ |
|||
var state = debugStates[debugStates.length - 1]; |
|||
debugStorageTxt.text = ""; |
|||
debugCallDataTxt.text = ""; |
|||
debugStackTxt.text = ""; |
|||
debugMemoryTxt.text = state.endOfDebug; |
|||
headerInfoLabel.text = "EXIT | GAS: " + state.gasLeft; |
|||
} |
|||
|
|||
function displayReturnValue() |
|||
{ |
|||
headerReturnList.model = contractCallReturnParameters; |
|||
headerReturnList.update(); |
|||
} |
|||
|
|||
function stepOutBack() |
|||
{ |
|||
if (jumpStartingPoint != null) |
|||
{ |
|||
select(jumpStartingPoint); |
|||
jumpStartingPoint = null; |
|||
jumpoutbackaction.state = "disabled"; |
|||
jumpoutforwardaction.state = "disabled"; |
|||
} |
|||
} |
|||
|
|||
function stepIntoBack() |
|||
{ |
|||
moveSelection(-1); |
|||
} |
|||
|
|||
function stepOverBack() |
|||
{ |
|||
var state = debugStates[currentSelectedState]; |
|||
if (state.instruction === "JUMPDEST") |
|||
{ |
|||
for (var k = currentSelectedState; k > 0; k--) |
|||
{ |
|||
var line = bytesCodeMapping.getValue(debugStates[k].curPC); |
|||
if (line === statesList.currentIndex - 2) |
|||
{ |
|||
select(k); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
var splitted = raw.split(':'); |
|||
if (!shortMessage) |
|||
return qsTr("Error in line ") + splitted[1] + ", " + qsTr("character ") + splitted[2]; |
|||
else |
|||
moveSelection(-1); |
|||
return "L" + splitted[1] + "," + "C" + splitted[2]; |
|||
} |
|||
|
|||
function stepOverForward() |
|||
function extractErrorInfo(raw, shortMessage) |
|||
{ |
|||
var state = debugStates[currentSelectedState]; |
|||
if (state.instruction === "JUMP") |
|||
var _return = {}; |
|||
var detail = raw.split('\n')[0]; |
|||
var reg = detail.match(/:\d+:\d+:/g); |
|||
if (reg !== null) |
|||
{ |
|||
for (var k = currentSelectedState; k < debugStates.length; k++) |
|||
{ |
|||
var line = bytesCodeMapping.getValue(debugStates[k].curPC); |
|||
if (line === statesList.currentIndex + 2) |
|||
{ |
|||
select(k); |
|||
break; |
|||
} |
|||
} |
|||
_return.errorLocation = ErrorLocationFormater.formatLocation(reg[0], shortMessage); |
|||
_return.errorDetail = detail.replace(reg[0], ""); |
|||
} |
|||
else |
|||
moveSelection(1); |
|||
} |
|||
|
|||
function stepIntoForward() |
|||
{ |
|||
var state = debugStates[currentSelectedState]; |
|||
if (state.instruction === "JUMP") |
|||
{ |
|||
jumpStartingPoint = currentSelectedState; |
|||
moveSelection(1); |
|||
jumpoutbackaction.state = ""; |
|||
jumpoutforwardaction.state = ""; |
|||
_return.errorLocation = ""; |
|||
_return.errorDetail = detail; |
|||
} |
|||
} |
|||
|
|||
function stepOutForward() |
|||
{ |
|||
if (jumpStartingPoint != null) |
|||
{ |
|||
stepOutBack(); |
|||
stepOverForward(); |
|||
jumpoutbackaction.state = "disabled"; |
|||
jumpoutforwardaction.state = "disabled"; |
|||
} |
|||
} |
|||
|
|||
function jumpTo(value) |
|||
{ |
|||
currentSelectedState = value; |
|||
select(currentSelectedState); |
|||
_return.errorLine = raw.split('\n')[1]; |
|||
return _return; |
|||
} |
|||
|
@ -1,68 +0,0 @@ |
|||
//humanReadableExecutionCode => contain human readable code.
|
|||
//debugStates => contain all debug states.
|
|||
//bytesCodeMapping => mapping between humanReadableExecutionCode and bytesCode.
|
|||
//statesList => ListView
|
|||
|
|||
var currentSelectedState = null; |
|||
function init() |
|||
{ |
|||
currentSelectedState = 0; |
|||
select(currentSelectedState); |
|||
displayReturnValue(); |
|||
} |
|||
|
|||
function moveSelection(incr) |
|||
{ |
|||
if (currentSelectedState + incr >= 0) |
|||
{ |
|||
if (currentSelectedState + incr < debugStates.length) |
|||
{ |
|||
select(currentSelectedState + incr); |
|||
} |
|||
else |
|||
{ |
|||
endOfDebug(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function select(stateIndex) |
|||
{ |
|||
var state = debugStates[stateIndex]; |
|||
var codeStr = bytesCodeMapping.getValue(state.curPC); |
|||
highlightSelection(codeStr); |
|||
currentSelectedState = stateIndex; |
|||
completeCtxInformation(state); |
|||
levelList.model = state.levels; |
|||
levelList.update(); |
|||
} |
|||
|
|||
function highlightSelection(index) |
|||
{ |
|||
statesList.currentIndex = index; |
|||
} |
|||
|
|||
function completeCtxInformation(state) |
|||
{ |
|||
debugStackTxt.text = state.debugStack; |
|||
debugStorageTxt.text = state.debugStorage; |
|||
debugMemoryTxt.text = state.debugMemory; |
|||
debugCallDataTxt.text = state.debugCallData; |
|||
headerInfoLabel.text = state.headerInfo |
|||
} |
|||
|
|||
function endOfDebug() |
|||
{ |
|||
var state = debugStates[debugStates.length - 1]; |
|||
debugStorageTxt.text = ""; |
|||
debugCallDataTxt.text = ""; |
|||
debugStackTxt.text = ""; |
|||
debugMemoryTxt.text = state.endOfDebug; |
|||
headerInfoLabel.text = "EXIT | GAS: " + state.gasLeft; |
|||
} |
|||
|
|||
function displayReturnValue() |
|||
{ |
|||
headerReturnList.model = contractCallReturnParameters; |
|||
headerReturnList.update(); |
|||
} |
Loading…
Reference in new issue