Commit 8ed80398 authored by Sebastian Biewer's avatar Sebastian Biewer

Removed unnecessary files (e.g. for earlt GUI)

parent 8d3f038c
CCS::getTraces = (weak, maxSteps) ->
maxSteps = Number.MAX_VALUE if not maxSteps
@system.getTraces(weak, maxSteps)
CCSProcess::_getTraces = (prefix, set, weak, maxSteps) ->
return if maxSteps.i-- < 0
#console.log maxSteps.i
steps = @getPossibleSteps(true)
if steps and steps.length > 0
# prefix = prefix + "." if prefix.length > 0
for s in steps
p = s.perform()
prefix2 = prefix
if not weak or not s.action.isInternalAction()
prefix2 = prefix2 + "." if prefix2.length > 0
prefix2 = prefix2 + s.toString()
p._getTraces(prefix2, set, weak, maxSteps)
else
set[prefix] = true
CCSProcess::getTraces = (weak, maxSteps) ->
maxSteps = Number.MAX_VALUE if not maxSteps
set = {}
@_getTraces("", set, weak, {"i": maxSteps})
res = []
for trace, b of set
res.push(trace) if b == true
res
CCSProcess::getFinalProcesses = ->
steps = @getPossibleSteps(true)
if steps and steps.length > 0
for s in steps
p = s.perform()
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
CCSExecutorCopyOnPerformStepPolicy = true
CCSExecutorStepCountPerExecutionUnit = 20
CCSExecutorDefaultStepPicker = (steps) ->
steps[0] # ToDo: random!
class CCSExecutor
constructor: (@ccs, @delegate) ->
execute: (system) ->
@prepareExecution(system)
{} while @continueExecution()
@finishExecution()
prepareExecution: (@system=@ccs.system.copy()) ->
throw new Error("No CCS system available!") if not @system
@_printExecutionIntro()
@executionStart = new Date()
@stepCount = 0
_printExecutionIntro: -> @_output("Starting CCS execution.")
continueExecution: ->
steps = @system.getPossibleSteps(CCSExecutorCopyOnPerformStepPolicy)
throw new Error("Time exceeded. Info: \n\t" + steps.join("\n\t")) if @stepCount > 5000
count = CCSExecutorStepCountPerExecutionUnit
while steps.length > 0 and count > 0
step = @_chooseStep(steps)
@_performStep(step)
@_printStep(step)
steps = @system.getPossibleSteps(CCSExecutorCopyOnPerformStepPolicy)
@stepCount++
count--
steps.length > 0
_printStep: (step) ->
if step.action.channel.name != CCSInternalChannel
exp = step.action.expression
value = if exp then exp.evaluate() else ""
value = "\"#{value}\"" if (exp.typeOfEvaluation() == "string")
value = ": #{value}"
if step.action.isOutputAction()
@_output("Output on channel <b>#{step.action.channel.toString()}</b>#{value}")
else if step.action.isInputAction()
@_output("Input on channel #{step.action.channel.toString()}#{value}")
else
@_output("Message on channel #{step.action.channel.toString()}")
finishExecution: ->
@_printExecutionSummary()
@system = null
_printExecutionSummary: ->
elapsedMS = ((new Date()).getTime()-@executionStart.getTime())
perStep = Math.round(elapsedMS / @stepCount * 100) / 100
@_output("Finished CCS execution after performing #{@stepCount} steps in #{elapsedMS/1000} seconds (#{perStep}ms per step).\n-------------------------------------------------------------------------------------------")
_output: (msg) -> @delegate.executorPrint(@, msg) if @delegate.executorPrint
_chooseStep: (steps) ->
if @delegate.executorChooseStep
@delegate.executorChooseStep(@, step)
else
CCSExecutorDefaultStepPicker(steps)
_performStep: (step) ->
@delegate.executorWillPerformStep(@, step) if @delegate.executorWillPerformStep
@system = step.perform()
@delegate.executorDidPerformStep(@, step, @system) if @delegate.executorDidPerformStep
@system
\ No newline at end of file
......@@ -46,7 +46,7 @@ exports["Restriction"] = CCSRestriction
exports["Channel"] = CCSChannel
exports["Action"] = CCSAction
exports["SimpleAction"] = CCSSimpleAction
# Private: CCSInternalActionCreate
exports["ValueSet"] = CCSValueSet
exports["Variable"] = CCSVariable
exports["Input"] = CCSInput
......@@ -69,7 +69,6 @@ exports["actionSets"] = ActionSets
exports["Step"] = CCSStep
exports["BaseStep"] = CCSBaseStep
# exports["InputStep"] = CCSInputStep
exports["PrefixRule"] = CCSPrefixRule
exports["OutputRule"] = CCSOutputRule
......@@ -89,11 +88,6 @@ exports["Seq2Rule"] = CCSSeq2Rule
exports["RecRule"] = CCSRecRule
# Private: CCSExecutorCopyOnPerformStepPolicy
# Private: CCSExecutorStepCountPerExecutionUnit
# Private: CCSExecutorDefaultStepPicker
exports["Executor"] = CCSExecutor
......
all: CCS PC PCC
pctree:
coffee -c -b -j node_modules/PseuCo/_tree.js PseuCo.coffee PCType.coffee PCEnvironment.coffee PCExport.coffee
ccsmain:
coffee -c -b -j node_modules/CCS/_main.js CCS.coffee CCSRules.coffee CCS+Traces.coffee CCSExecutor.coffee CCSExport.coffee
ccsparser:
pegjs -e CCSParser CCSParser.pegjs node_modules/CCS/_parser.js
pcparser:
pegjs -e PseuCoParser PseuCoParser.pegjs node_modules/PseuCo/_parser.js
PCC:
coffee -c -b -j node_modules/CCSCompiler/CCSCompiler.js PCCCompiler.coffee PCCProcessFrame.coffee PCCProgramController.coffee PCCContainer.coffee PCCCompilerStack.coffee PseuCo+Compiler.coffee PCCExecutor.coffee PCCExport.coffee
PC: pctree pcparser
cat node_modules/PseuCo/_parser.js node_modules/PseuCo/_tree.js > node_modules/PseuCo/PseuCo.js
CCS: ccsmain ccsparser
cat node_modules/CCS/_parser.js node_modules/CCS/_main.js > node_modules/CCS/CCS.js
......@@ -63,11 +63,6 @@ exports["UnaryContainer"] = PCCUnaryContainer
exports["Executor"] = PCCExecutor
exports["ProcessFrame"] = PCCProcessFrame
exports["ProcedureFrame"] = PCCProcedureFrame
exports["Groupable"] = PCCGroupable
......
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
class UIAppController
constructor: (@pseuCoEditor, @ccsEditor, @executor, @console, @history) ->
@observers = [@pseuCoEditor, @ccsEditor, @executor, @console, @history]
@stepObservers = [@console, @history]
didChangeEditorState: (editor) ->
o.appDidChangeEditorState?(@, editor) for o in @observers
null
didUpdateConsole: (console) ->
o.appDidUpdateConsole?(@, console) for o in @observers
null
willChangeCCS: (newCCS) ->
o.appWillChangeCCS?(@, newCCS) for o in @observers
null
didChangeCCS: (newCCS) ->
o.appDidChangeCCS?(@, newCCS) for o in @observers
null
setCCS: (newCCS) ->
@willChangeCCS(newCCS)
@ccs = newCCS
@system = null
@didChangeCCS(newCCS)
resetCCS: ->
@system = @ccs.system.copy()
o.appDidResetCCS?(@, @system) for o in @observers
@system
willPerformStep: (step) ->
o.appWillPerformStep?(@, step) for o in @stepObservers
null
didPerformStep: (step) ->
o.appDidPerformStep?(@, step) for o in @stepObservers
null
performStep: (step) ->
throw new Error("Cannot perform step when no CCS is available!") if not @ccs
@willPerformStep step
@system = @history.performStep step
if step.action.channel.name == "println" and step.action.isOutputAction() and step.action.expression
UILog "#{step.action.expression.evaluate()}"
@didPerformStep step
willOpenDocument: (document) ->
# Coming later...
didOpenDocument: (document) ->
# Coming later...
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
class UICCSEditor
constructor: (@textarea) ->
appDidChangeEditorState: (app, editor) ->
return if editor != app.pseuCoEditor or editor.state != UIEditorState.valid
compiler = new PCC.Compiler(editor.tree)
ccs = compiler.compileProgram()
app.setCCS(ccs)
appDidChangeCCS: (app, newCCS) ->
@textarea.value = newCCS.toString()
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
class UICCSHistory
constructor: (@container) -> @clear()
appDidResetCCS: (app, system) ->
@clear()
@system = system
@_addState(null)
clear: ->
@system = null
@container.innerHTML = ""
@stepStack = []
performStep: (step) ->
throw new Error("Step must not be null!") if not step
@addState step, step.perform()
@system
addState: (step, newSystem) ->
@stepStack.push step if step.copyOnPerform
@system = newSystem
action = ""
if step
action = step.action.transferDescription()
details = ""
if step.actionDetails
details = step.actionDetails
if details.length > 0
details = " <span class=\"action_detail\">(#{details})</span>"
action = "<span class=\"h_action\">#{action}#{details}</span>"
system = "<span class=\"h_ccs\">#{@system.toString()}</span>"
li = document.createElement("LI")
li.innerHTML = action + system
if @container.hasChildNodes()
@container.insertBefore(li, @container.firstChild)
else
@container.appendChild(li)
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
class UIConsole
constructor: (div) ->
div.innerHTML = ""
@ul = document.createElement("UL")
div.appendChild(@ul)
addLine: (str, cssClass) ->
str = str.replace(/\n/g, "<br />")
str = str.replace(/\t/g, "&nbsp;&nbsp;&nbsp;")
node = document.createElement("LI")
cssClass = if cssClass then "log " + cssClass else "log"
node.setAttribute("CLASS", cssClass)
node.innerHTML = str
@ul.appendChild(node)
@ul.getTabBar().scrollTo(0, @ul.offsetHeight)
bar = @ul.getTabBar()
bar.setItemAtIndex(bar.getIndexForContent(@ul))
UI.app.didUpdateConsole(@)
node
log: (msg) -> @addLine(msg)
warn: (msg) -> @addLine(msg, "warning")
error: (msg) -> @addLine(msg, "error")
clear: -> @ul.innerHTML = ""
class UICCSConsole extends UIConsole
addOutput: (action) -> @addLine("&gt;&gt;&gt; #{action.toString()}")
addInput: (action) -> @addLine("&lt;&lt;&lt; #{action.toString()}")
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
###
Delegate methods:
recognizerShouldBeginRecognising()
recognizerDidChangeState()
###
class UIEventRecognizer
constructor: (@nodes, @delegate) ->
@setEnabled(true)
@state = UIEventRecognizer.POSSIBLE
setEnabled: (enabled) ->
return if enabled == @enabled
@nabled = enabled
if @enabled then @_enable() else @_disable()
_enable: -> throw new Error("Not implemented!")
_disable: -> throw new Error("Not implemented!")
UIEventRecognizer.POSSIBLE = 0
UIEventRecognizer.BEGAN = 1
UIEventRecognizer.CHANGED = 2
UIEventRecognizer.ENDED = 3
UIEventRecognizer.RECOGNIZED = 3
class UIClickRecognizer extends UIEventRecognizer
constructor: ->
super
@requiredClicks = 1
_enable: ->
@nodes.on("click", (event) -> )
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###
class UIExecutor
constructor: (@button) ->
@button.__executor = @
$(@button).on("click", (event) -> event.target.__executor.execute())
_enableButton: -> @button.removeAttribute("DISABLED")
_disableButton: -> @button.setAttribute("DISABLED", "disabled")
setButtonEnabled: (enabled) -> if enabled then @_enableButton() else @_disableButton()
appWillChangeCCS: (app) -> @setButtonEnabled(false)
appDidChangeCCS: (app) -> @setButtonEnabled(if app.ccs then true else false)
# Executor delegate
executorPrint: (exec, msg) ->
UILog msg
executorDidPerformStep: (exec, step, system) ->
# Tell app..
execute: ->
@executor = new PCC.Executor(UI.app.ccs, @)
@executor.execute()
executorDidPerformStep: (exec, step, system) ->
UI.history.addState(step, system)
# @setButtonEnabled(false)
# app = UI.app
# app.resetCCS()
# debugger
# return if not ccs
# UILog("Starting CCS execution.")
# t = new Date()
# steps = app.system.getPossibleSteps()
# stepCount = 0
# while steps.length > 0
# app.performStep(steps[0])
# steps = app.system.getPossibleSteps()
# stepCount++
# elapsedMS = ((new Date()).getTime()-t.getTime())
# perStep = Math.round(elapsedMS / stepCount * 100) / 100
# UILog("Finished CCS execution after performing #{stepCount} steps in #{elapsedMS/1000} seconds (#{perStep}ms per step).\n-------------------------------------------------------------------------------------------")
# @setButtonEnabled(if UI.app.ccs then true else false)
\ No newline at end of file
###
PseuCo Compiler
Copyright (C) 2013
Saarland University (www.uni-saarland.de)
Sebastian Biewer (biewer@splodge.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
###