Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
(fix) version of composer with JSON serialization for concepts
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Jun 3, 2018
1 parent 83ceeb2 commit c2453e4
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 629 deletions.
22 changes: 1 addition & 21 deletions mechanization/Translation/ErgoCalculustoJavaScriptCicero.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Section ErgoCalculustoJavaScriptCicero.
eol
quotel)
++ "function " ++ fun_name ++ "(context) {" ++ eol
++ " let pcontext = { 'request' : serializer.toJSON(context.request,{permitResourcesForRelationships:true}), 'state': serializer.toJSON(context.state,{permitResourcesForRelationships:true}), 'contract': context.contract, 'emit': context.emit, 'now': context.now};" ++ eol
++ " let pcontext = { 'request' : serializer.toJSON(context.request,{permitResourcesForRelationships:true}), 'state': serializer.toJSON(context.state,{permitResourcesForRelationships:true}), 'contract': serializer.toJSON(context.contract,{permitResourcesForRelationships:true}), 'emit': context.emit, 'now': context.now};" ++ eol
++ " let result = new " ++ contract_name ++ "()." ++ clause_name ++ "(pcontext);" ++ eol
++ " if (result.hasOwnProperty('left')) {" ++ eol
++ " //logger.info('ergo result'+JSON.stringify(result))" ++ eol
Expand All @@ -76,25 +76,6 @@ Section ErgoCalculustoJavaScriptCicero.
++ " }" ++ eol
++ "}" ++ eol.

Definition dispatch_function
(contract_name:string)
(eol:string)
(quotel:string) : string :=
(accord_annotation
CTO.request_type
CTO.response_type
eol
quotel)
++ "function __dispatch(contract,request,state,now) {" ++ eol
++ " let context = { 'request' : serializer.toJSON(request,{permitResourcesForRelationships:true}), 'state': serializer.toJSON(state,{permitResourcesForRelationships:true}), 'contract': contract, 'emit': [], 'now': now};" ++ eol
++ " let result = new " ++ contract_name ++ "()." ++ clause_main_name ++ "(context);" ++ eol
++ " if (result.hasOwnProperty('left')) {" ++ eol
++ " return { 'response' : serializer.fromJSON(result.left.response,{permitResourcesForRelationships:true}), 'state' :serializer.fromJSON(result.left.state,{permitResourcesForRelationships:true}), 'emit' : result.left.emit };" ++ eol
++ " } else {" ++ eol
++ " return { 'error' : result.right };" ++ eol
++ " }" ++ eol
++ "}" ++ eol.

Definition apply_wrapper_function
(contract_name:string)
(signature:string * string * string)
Expand All @@ -120,7 +101,6 @@ Section ErgoCalculustoJavaScriptCicero.
(quotel:string) : ErgoCodeGen.ergoc_javascript :=
(preamble eol) ++ eol
++ (wrapper_functions contract_name signatures eol quotel)
(* ++ (dispatch_function contract_name eol quotel) ++ eol *)
++ (javascript_of_declarations p.(packagec_declarations) 0 0 eol quotel)
++ (postamble eol).

Expand Down
Loading

0 comments on commit c2453e4

Please sign in to comment.