Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
afa87c96
Commit
afa87c96
authored
Aug 11, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
register event in inner class
parent
d172d68b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
59 deletions
+66
-59
app.js
src/app.js
+11
-30
compiler.js
src/app/compiler.js
+6
-6
debugger.js
src/app/debugger.js
+9
-1
execution-context.js
src/app/execution-context.js
+1
-1
formalVerification.js
src/app/formalVerification.js
+17
-10
renderer.js
src/app/renderer.js
+17
-1
util.js
src/lib/util.js
+0
-9
universal-dapp.js
src/universal-dapp.js
+3
-0
compiler-test.js
test/compiler-test.js
+2
-1
No files found.
src/app.js
View file @
afa87c96
...
@@ -28,7 +28,7 @@ window.addEventListener('message', function (ev) {
...
@@ -28,7 +28,7 @@ window.addEventListener('message', function (ev) {
}
}
},
false
);
},
false
);
/*
/*
trigger
selectTab
trigger
tabChanged
*/
*/
var
run
=
function
()
{
var
run
=
function
()
{
var
self
=
this
;
var
self
=
this
;
...
@@ -411,7 +411,6 @@ var run = function () {
...
@@ -411,7 +411,6 @@ var run = function () {
setEditorSize
(
hidingRHP
?
0
:
storage
.
getEditorSize
());
setEditorSize
(
hidingRHP
?
0
:
storage
.
getEditorSize
());
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-right'
,
!
hidingRHP
);
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-right'
,
!
hidingRHP
);
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-left'
,
hidingRHP
);
$
(
'.toggleRHP i'
).
toggleClass
(
'fa-angle-double-left'
,
hidingRHP
);
if
(
!
hidingRHP
)
compiler
.
compile
();
});
});
// ----------------- editor resize ---------------
// ----------------- editor resize ---------------
...
@@ -436,9 +435,9 @@ var run = function () {
...
@@ -436,9 +435,9 @@ var run = function () {
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading github.com/'
+
root
+
'/'
+
path
+
' ...'
)));
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading github.com/'
+
root
+
'/'
+
path
+
' ...'
)));
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
,
cb
);
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
,
cb
);
}
}
var
transactionDebugger
=
new
Debugger
(
'#debugger'
);
var
executionContext
=
new
ExecutionContext
();
var
executionContext
=
new
ExecutionContext
();
var
transactionDebugger
=
new
Debugger
(
'#debugger'
,
executionContext
.
event
);
transactionDebugger
.
addProvider
(
'VM'
,
executionContext
.
vm
());
transactionDebugger
.
addProvider
(
'VM'
,
executionContext
.
vm
());
transactionDebugger
.
switchProvider
(
'VM'
);
transactionDebugger
.
switchProvider
(
'VM'
);
transactionDebugger
.
addProvider
(
'INTERNAL'
,
executionContext
.
web3
());
transactionDebugger
.
addProvider
(
'INTERNAL'
,
executionContext
.
web3
());
...
@@ -456,44 +455,26 @@ var run = function () {
...
@@ -456,44 +455,26 @@ var run = function () {
transactionDebugger
.
debug
(
data
);
transactionDebugger
.
debug
(
data
);
});
});
var
renderer
=
new
Renderer
(
editor
,
executionContext
.
web3
(),
updateFiles
,
udapp
,
executionContext
);
var
formalVerification
=
new
FormalVerification
(
$
(
'#verificationView'
));
formalVerification
.
event
.
register
(
'compilationError'
,
this
,
function
(
message
,
container
,
noAnnotations
)
{
renderer
.
error
(
message
,
container
,
noAnnotations
);
});
var
compiler
=
new
Compiler
(
editor
,
queryParams
,
handleGithubCall
,
updateFiles
);
var
compiler
=
new
Compiler
(
editor
,
queryParams
,
handleGithubCall
,
updateFiles
);
var
formalVerification
=
new
FormalVerification
(
$
(
'#verificationView'
),
compiler
.
event
);
var
renderer
=
new
Renderer
(
editor
,
executionContext
.
web3
(),
updateFiles
,
udapp
,
executionContext
,
formalVerification
.
event
,
compiler
.
event
);
// eslint-disable-line
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
executionContext
.
event
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
$
(
'#output'
).
empty
();
context
=
context
===
'vm'
?
'VM'
:
context
;
context
=
context
===
'injected'
?
'EXTERNAL'
:
context
;
context
=
context
===
'web3'
?
'INTERNAL'
:
context
;
transactionDebugger
.
switchProvider
(
context
);
compiler
.
compile
();
compiler
.
compile
();
});
});
executionContext
.
event
.
register
(
'web3EndpointChanged'
,
this
,
function
(
context
)
{
executionContext
.
event
.
register
(
'web3EndpointChanged'
,
this
,
function
(
context
)
{
$
(
'#output'
).
empty
();
compiler
.
compile
();
compiler
.
compile
();
});
});
executionContext
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
context
)
{
compiler
.
compile
();
});
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
setVersionText
(
version
);
setVersionText
(
version
);
compiler
.
compile
();
compiler
.
compile
();
});
});
compiler
.
event
.
register
(
'compilationError'
,
this
,
function
(
data
)
{
renderer
.
error
(
data
);
});
compiler
.
event
.
register
(
'compilationSucceed'
,
this
,
function
(
data
,
source
)
{
if
(
!
hidingRHP
)
{
renderer
.
contracts
(
data
,
source
);
formalVerification
.
compilationFinished
(
data
);
}
});
compiler
.
event
.
register
(
'isCompiling'
,
this
,
function
()
{
$
(
'#output'
).
empty
();
formalVerification
.
compiling
();
});
function
setVersionText
(
text
)
{
function
setVersionText
(
text
)
{
$
(
'#version'
).
text
(
text
);
$
(
'#version'
).
text
(
text
);
...
...
src/app/compiler.js
View file @
afa87c96
...
@@ -8,7 +8,7 @@ var Base64 = require('js-base64').Base64;
...
@@ -8,7 +8,7 @@ var Base64 = require('js-base64').Base64;
var
EventManager
=
require
(
'../lib/eventManager'
);
var
EventManager
=
require
(
'../lib/eventManager'
);
/*
/*
trigger compilation
Error, compilationSucceed, compilerLoaded, isCompiling
trigger compilation
Finished, compilerLoaded, compilationStarted
*/
*/
function
Compiler
(
editor
,
queryParams
,
handleGithubCall
,
updateFiles
)
{
function
Compiler
(
editor
,
queryParams
,
handleGithubCall
,
updateFiles
)
{
var
self
=
this
;
var
self
=
this
;
...
@@ -44,7 +44,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
...
@@ -44,7 +44,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
var
compile
=
function
(
missingInputs
)
{
var
compile
=
function
(
missingInputs
)
{
editor
.
clearAnnotations
();
editor
.
clearAnnotations
();
self
.
event
.
trigger
(
'
isCompiling
'
,
[]);
self
.
event
.
trigger
(
'
compilationStarted
'
,
[]);
var
input
=
editor
.
getValue
();
var
input
=
editor
.
getValue
();
editor
.
setCacheFileContent
(
input
);
editor
.
setCacheFileContent
(
input
);
...
@@ -52,7 +52,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
...
@@ -52,7 +52,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
files
[
utils
.
fileNameFromKey
(
editor
.
getCacheFile
())]
=
input
;
files
[
utils
.
fileNameFromKey
(
editor
.
getCacheFile
())]
=
input
;
gatherImports
(
files
,
missingInputs
,
function
(
input
,
error
)
{
gatherImports
(
files
,
missingInputs
,
function
(
input
,
error
)
{
if
(
input
===
null
)
{
if
(
input
===
null
)
{
this
.
event
.
trigger
(
'compilation
Error'
,
[
error
]);
this
.
event
.
trigger
(
'compilation
Finished'
,
[
false
,
error
,
editor
.
getValue
()
]);
}
else
{
}
else
{
var
optimize
=
queryParams
.
get
().
optimize
;
var
optimize
=
queryParams
.
get
().
optimize
;
compileJSON
(
input
,
optimize
?
1
:
0
);
compileJSON
(
input
,
optimize
?
1
:
0
);
...
@@ -102,14 +102,14 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
...
@@ -102,14 +102,14 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
var
noFatalErrors
=
true
;
// ie warnings are ok
var
noFatalErrors
=
true
;
// ie warnings are ok
if
(
data
[
'error'
]
!==
undefined
)
{
if
(
data
[
'error'
]
!==
undefined
)
{
self
.
event
.
trigger
(
'compilation
Error'
,
[
data
[
'error'
]
]);
self
.
event
.
trigger
(
'compilation
Finished'
,
[
false
,
[
data
[
'error'
]],
editor
.
getValue
()
]);
if
(
utils
.
errortype
(
data
[
'error'
])
!==
'warning'
)
{
if
(
utils
.
errortype
(
data
[
'error'
])
!==
'warning'
)
{
noFatalErrors
=
false
;
noFatalErrors
=
false
;
}
}
}
}
if
(
data
[
'errors'
]
!==
undefined
)
{
if
(
data
[
'errors'
]
!==
undefined
)
{
self
.
event
.
trigger
(
'compilationFinished'
,
[
false
,
data
[
'errors'
],
editor
.
getValue
()]);
data
[
'errors'
].
forEach
(
function
(
err
)
{
data
[
'errors'
].
forEach
(
function
(
err
)
{
self
.
event
.
trigger
(
'compilationError'
,
[
err
]);
if
(
utils
.
errortype
(
err
)
!==
'warning'
)
{
if
(
utils
.
errortype
(
err
)
!==
'warning'
)
{
noFatalErrors
=
false
;
noFatalErrors
=
false
;
}
}
...
@@ -119,7 +119,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
...
@@ -119,7 +119,7 @@ function Compiler (editor, queryParams, handleGithubCall, updateFiles) {
if
(
missingInputs
!==
undefined
&&
missingInputs
.
length
>
0
)
{
if
(
missingInputs
!==
undefined
&&
missingInputs
.
length
>
0
)
{
compile
(
missingInputs
);
compile
(
missingInputs
);
}
else
if
(
noFatalErrors
)
{
}
else
if
(
noFatalErrors
)
{
self
.
event
.
trigger
(
'compilation
Succeed'
,
[
data
,
editor
.
getValue
()]);
self
.
event
.
trigger
(
'compilation
Finished'
,
[
true
,
data
,
editor
.
getValue
()]);
}
}
}
}
...
...
src/app/debugger.js
View file @
afa87c96
var
remix
=
require
(
'ethereum-remix'
);
var
remix
=
require
(
'ethereum-remix'
);
function
Debugger
(
id
)
{
function
Debugger
(
id
,
executionContextEvent
)
{
this
.
el
=
document
.
querySelector
(
id
);
this
.
el
=
document
.
querySelector
(
id
);
this
.
debugger
=
new
remix
.
ui
.
Debugger
();
this
.
debugger
=
new
remix
.
ui
.
Debugger
();
this
.
el
.
appendChild
(
this
.
debugger
.
render
());
this
.
el
.
appendChild
(
this
.
debugger
.
render
());
var
self
=
this
;
executionContextEvent
.
register
(
'contextChanged'
,
this
,
function
(
context
)
{
context
=
context
===
'vm'
?
'VM'
:
context
;
context
=
context
===
'injected'
?
'EXTERNAL'
:
context
;
context
=
context
===
'web3'
?
'INTERNAL'
:
context
;
self
.
switchProvider
(
context
);
});
}
}
Debugger
.
prototype
.
debug
=
function
(
receipt
)
{
Debugger
.
prototype
.
debug
=
function
(
receipt
)
{
...
...
src/app/execution-context.js
View file @
afa87c96
...
@@ -19,7 +19,7 @@ var vm = new EthJSVM(null, null, { activatePrecompiles: true, enableHomestead: t
...
@@ -19,7 +19,7 @@ var vm = new EthJSVM(null, null, { activatePrecompiles: true, enableHomestead: t
vm
.
stateManager
.
checkpoint
();
vm
.
stateManager
.
checkpoint
();
/*
/*
trigger contextChanged
trigger contextChanged
, web3EndpointChanged
*/
*/
function
ExecutionContext
()
{
function
ExecutionContext
()
{
...
...
src/app/formalVerification.js
View file @
afa87c96
...
@@ -2,23 +2,28 @@ var $ = require('jquery');
...
@@ -2,23 +2,28 @@ var $ = require('jquery');
var
EventManager
=
require
(
'../lib/eventManager'
);
var
EventManager
=
require
(
'../lib/eventManager'
);
/*
/*
trigger compilation
Error
trigger compilation
Finished
*/
*/
function
FormalVerification
(
outputElement
)
{
function
FormalVerification
(
outputElement
,
compilerEvent
)
{
this
.
event
=
new
EventManager
();
this
.
event
=
new
EventManager
();
this
.
outputElement
=
outputElement
;
this
.
outputElement
=
outputElement
;
}
var
self
=
this
;
compilerEvent
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
FormalVerification
.
prototype
.
compiling
=
function
()
{
if
(
success
)
{
$
(
'#formalVerificationInput'
,
this
.
outputElement
)
self
.
compilationFinished
(
data
);
}
});
compilerEvent
.
register
(
'compilationStarted'
,
this
,
function
()
{
$
(
'#formalVerificationInput'
,
self
.
outputElement
)
.
val
(
''
)
.
val
(
''
)
.
hide
();
.
hide
();
$
(
'#formalVerificationErrors'
).
empty
();
$
(
'#formalVerificationErrors'
).
empty
();
};
});
}
FormalVerification
.
prototype
.
compilationFinished
=
function
(
compilationResult
)
{
FormalVerification
.
prototype
.
compilationFinished
=
function
(
compilationResult
)
{
if
(
compilationResult
.
formal
===
undefined
)
{
if
(
compilationResult
.
formal
===
undefined
)
{
this
.
event
.
trigger
(
'compilation
Error'
,
[
'Formal verification not supported by this compiler version.'
,
$
(
'#formalVerificationErrors'
),
true
]);
this
.
event
.
trigger
(
'compilation
Finished'
,
[
false
,
'Formal verification not supported by this compiler version.'
,
$
(
'#formalVerificationErrors'
),
true
]);
}
else
{
}
else
{
if
(
compilationResult
.
formal
[
'why3'
]
!==
undefined
)
{
if
(
compilationResult
.
formal
[
'why3'
]
!==
undefined
)
{
$
(
'#formalVerificationInput'
,
this
.
outputElement
).
val
(
$
(
'#formalVerificationInput'
,
this
.
outputElement
).
val
(
...
@@ -30,8 +35,10 @@ FormalVerification.prototype.compilationFinished = function (compilationResult)
...
@@ -30,8 +35,10 @@ FormalVerification.prototype.compilationFinished = function (compilationResult)
if
(
compilationResult
.
formal
.
errors
!==
undefined
)
{
if
(
compilationResult
.
formal
.
errors
!==
undefined
)
{
var
errors
=
compilationResult
.
formal
.
errors
;
var
errors
=
compilationResult
.
formal
.
errors
;
for
(
var
i
=
0
;
i
<
errors
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
errors
.
length
;
i
++
)
{
this
.
event
.
trigger
(
'compilation
Error'
,
[
errors
[
i
],
$
(
'#formalVerificationErrors'
),
true
]);
this
.
event
.
trigger
(
'compilation
Finished'
,
[
false
,
errors
[
i
],
$
(
'#formalVerificationErrors'
),
true
]);
}
}
}
else
{
this
.
event
.
trigger
(
'compilationFinished'
,
[
true
,
null
,
null
,
true
]);
}
}
}
}
};
};
...
...
src/app/renderer.js
View file @
afa87c96
...
@@ -3,12 +3,28 @@ var $ = require('jquery');
...
@@ -3,12 +3,28 @@ var $ = require('jquery');
var
utils
=
require
(
'./utils'
);
var
utils
=
require
(
'./utils'
);
var
uiHelper
=
require
(
'./ui-helper'
);
var
uiHelper
=
require
(
'./ui-helper'
);
function
Renderer
(
editor
,
web3
,
updateFiles
,
udapp
,
executionContext
)
{
function
Renderer
(
editor
,
web3
,
updateFiles
,
udapp
,
executionContext
,
formalVerificationEvent
,
compilerEvent
)
{
this
.
editor
=
editor
;
this
.
editor
=
editor
;
this
.
web3
=
web3
;
this
.
web3
=
web3
;
this
.
updateFiles
=
updateFiles
;
this
.
updateFiles
=
updateFiles
;
this
.
udapp
=
udapp
;
this
.
udapp
=
udapp
;
this
.
executionContext
=
executionContext
;
this
.
executionContext
=
executionContext
;
var
self
=
this
;
formalVerificationEvent
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
message
,
container
,
noAnnotations
)
{
if
(
!
success
)
{
self
.
error
(
message
,
container
,
noAnnotations
);
}
});
compilerEvent
.
register
(
'compilationFinished'
,
this
,
function
(
success
,
data
,
source
)
{
$
(
'#output'
).
empty
();
if
(
success
)
{
self
.
contracts
(
data
,
source
);
}
else
{
data
.
forEach
(
function
(
err
)
{
self
.
error
(
err
);
});
}
});
}
}
Renderer
.
prototype
.
error
=
function
(
message
,
container
,
noAnnotations
)
{
Renderer
.
prototype
.
error
=
function
(
message
,
container
,
noAnnotations
)
{
...
...
src/lib/util.js
deleted
100644 → 0
View file @
d172d68b
'use strict'
;
module
.
exports
=
{
extend
:
function
(
destination
,
source
)
{
for
(
var
property
in
source
)
{
destination
[
property
]
=
source
[
property
];
}
}
};
src/universal-dapp.js
View file @
afa87c96
...
@@ -8,6 +8,9 @@ var EthJSBlock = require('ethereumjs-block');
...
@@ -8,6 +8,9 @@ var EthJSBlock = require('ethereumjs-block');
var
BN
=
ethJSUtil
.
BN
;
var
BN
=
ethJSUtil
.
BN
;
var
EventManager
=
require
(
'./lib/eventManager'
);
var
EventManager
=
require
(
'./lib/eventManager'
);
/*
trigger debugRequested
*/
function
UniversalDApp
(
executionContext
,
options
,
txdebugger
)
{
function
UniversalDApp
(
executionContext
,
options
,
txdebugger
)
{
this
.
event
=
new
EventManager
();
this
.
event
=
new
EventManager
();
var
self
=
this
;
var
self
=
this
;
...
...
test/compiler-test.js
View file @
afa87c96
var
test
=
require
(
'tape'
);
var
test
=
require
(
'tape'
);
var
Compiler
=
require
(
'../src/app/compiler'
);
var
Compiler
=
require
(
'../src/app/compiler'
);
var
EventManager
=
require
(
'../src/lib/eventManager'
);
test
(
'compiler.compile smoke'
,
function
(
t
)
{
test
(
'compiler.compile smoke'
,
function
(
t
)
{
t
.
plan
(
1
);
t
.
plan
(
1
);
...
@@ -9,7 +10,7 @@ test('compiler.compile smoke', function (t) {
...
@@ -9,7 +10,7 @@ test('compiler.compile smoke', function (t) {
var
getCacheFile
=
function
()
{
return
'fakeCacheFile'
;
};
var
getCacheFile
=
function
()
{
return
'fakeCacheFile'
;
};
var
fakeEditor
=
{
onChangeSetup
:
noop
,
clearAnnotations
:
noop
,
getValue
:
noop
,
setCacheFileContent
:
noop
,
getCacheFile
:
getCacheFile
};
var
fakeEditor
=
{
onChangeSetup
:
noop
,
clearAnnotations
:
noop
,
getValue
:
noop
,
setCacheFileContent
:
noop
,
getCacheFile
:
getCacheFile
};
var
fakeQueryParams
=
{
get
:
function
()
{
return
{};
}};
var
fakeQueryParams
=
{
get
:
function
()
{
return
{};
}};
var
compiler
=
new
Compiler
(
fakeEditor
,
fakeQueryParams
,
null
,
null
);
var
compiler
=
new
Compiler
(
fakeEditor
,
fakeQueryParams
,
null
,
null
,
new
EventManager
()
);
compiler
.
setCompileJSON
(
noop
);
compiler
.
setCompileJSON
(
noop
);
compiler
.
compile
();
compiler
.
compile
();
t
.
ok
(
compiler
);
t
.
ok
(
compiler
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment