Permalink
Browse files

Deleted more things, moved things around.

  • Loading branch information...
1 parent ffa75cc commit cc6ad9dde0925515d2741957bc3e3552d9ea40d2 @jbeard4 committed Mar 27, 2012
Showing with 0 additions and 1,898 deletions.
  1. +0 −15 lib/node/index.coffee
  2. +0 −123 lib/optimization/class.coffee
  3. +0 −58 lib/optimization/initializer.coffee
  4. +0 −106 lib/optimization/state-table.coffee
  5. +0 −90 lib/optimization/switch.coffee
  6. +0 −28 lib/optimization/transition-optimizer.coffee
  7. +0 −31 lib/runner.coffee
  8. +0 −22 lib/scxml/async-for.coffee
  9. +0 −22 lib/scxml/doc2json.coffee
  10. 0 lib/{util → scxml}/set/ArraySet.coffee
  11. 0 lib/{util → scxml}/set/BitVector.coffee
  12. 0 lib/{util → scxml}/set/BooleanArray.coffee
  13. 0 lib/{util → scxml}/set/ObjectSet.coffee
  14. +0 −47 lib/test-harness/basic-test-harness.coffee
  15. +0 −62 lib/test-harness/browser-harness.coffee
  16. +0 −139 lib/test-harness/harness.coffee
  17. +0 −247 lib/test-harness/multi-process/client.coffee
  18. +0 −74 lib/test-harness/multi-process/initialize-json-test-descriptor.coffee
  19. +0 −58 lib/test-harness/multi-process/json-tests.coffee
  20. +0 −64 lib/test-harness/multi-process/scxml.coffee
  21. +0 −238 lib/test-harness/multi-process/server.coffee
  22. +0 −23 lib/test-harness/node-optimization-harness.coffee
  23. +0 −115 lib/test-harness/optimization-harness.coffee
  24. +0 −23 lib/test-harness/report2string.coffee
  25. +0 −29 lib/test-harness/rhino-optimization-harness.coffee
  26. +0 −18 lib/test-harness/simple-browser-test.coffee
  27. +0 −33 lib/test-harness/simple-browser-test.html
  28. +0 −49 lib/test-harness/simple-env.coffee
  29. +0 −17 lib/test-harness/simple-node-test.coffee
  30. +0 −25 lib/test-harness/spartan-optimization-harness.coffee
  31. +0 −37 lib/util/BufferedStream.coffee
  32. +0 −24 lib/util/memory.coffee
  33. +0 −25 lib/util/readline.coffee
  34. +0 −34 lib/util/reduce.coffee
  35. +0 −22 lib/util/utils.coffee
View
@@ -1,15 +0,0 @@
-#this module exposes the main scion modules to node
-requirejs = require 'requirejs'
-
-#Pass the top-level main.js/index.js require
-#function to requirejs so that node modules
-#are loaded relative to the top-level JS file.
-requirejs.config
- nodeRequire: require,
- baseUrl : __dirname + "/.."
-
-requirejs ['scxml/SCXML', 'scxml/event', 'scxml/json2model','util/annotate-scxml-json'], ({NodeInterpreter : NodeInterpreter }, Event, json2model, annotator) ->
- exports.NodeInterpreter = NodeInterpreter
- exports.Event = Event
- exports.json2model = json2model
- exports.annotateScxmlJson = annotator
@@ -1,123 +0,0 @@
-# Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-define ["optimization/initializer","lib/beautify"],(initializer,js_beautify)->
- (scxmlJson,beautify=true,asyncModuleDef=true) ->
-
- #the SCXML spec states that events must be alphanumeric, so picking out special strings to use as event names is technically safe
- WILDCARD_EVENT_NAME = "*"
- DEFAULT_EVENT_NAME = " "
-
- generateMethod = (eventName,transitions,parent) ->
- """
- this['#{eventName}'] = function(evaluator){
- var toReturn = [];
- var transitions = #{initializer.arrayToIdentifierListString transitions};
- for(var i = 0,l=transitions.length; i < l; i++){
- var transition = transitions[i];
- if(!transition.cond || evaluator(transition)){
- toReturn.push(transition);
- }
- }
-
- return toReturn.length ? toReturn : #{if parent then "instances['#{parent.id}']['#{eventName}'](evaluator)" else "null"};
- };
- """
-
- generateStateClassString = (state) ->
- classStr = """
- instances['#{state.id}'] = (function(){
- var o = {
- "#{state.id}" : function(){
- """
- if state.parent
-
- parent = state.parent
-
- #NOTE: scxmlJson.events will not contain wildcard ("*") event,
- #and will normalize events like "foo.bat.*" to "foo.bat"
- for own eventName of scxmlJson.events
- transitionsForEvent = (initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and eventName in transition.events )
-
- if transitionsForEvent.length
- classStr += generateMethod eventName,transitionsForEvent,parent
-
- defaultTransitionsForEvent = (initializer.transitionToVarLabel transition for transition in state.transitions when not transition.events)
- if defaultTransitionsForEvent.length
- classStr += generateMethod DEFAULT_EVENT_NAME,defaultTransitionsForEvent,parent
-
- wildcardTransitionsForEvent = (initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and "*" in transition.events)
- if wildcardTransitionsForEvent.length
- classStr += generateMethod WILDCARD_EVENT_NAME,wildcardTransitionsForEvent,parent
- else
- #root state
- for own eventName of scxmlJson.events
- classStr += "this['#{eventName}'] = function(){return null;};\n"
- classStr += "this['#{DEFAULT_EVENT_NAME}'] = function(){return null;};\n"
- classStr += "this['#{WILDCARD_EVENT_NAME}'] = function(){return null;};\n"
-
- classStr += """
- }
- };
- """
- classStr += if state.parent then "o['#{state.id}'].prototype = instances['#{state.parent.id}'];" else ""
- classStr += """
- return new o['#{state.id}']();
- })();
- """
-
- return classStr
-
- toReturn = ""
-
- stateClassStrings = (generateStateClassString(state) for state in scxmlJson.states)
-
- stateClassNameList = ("instances['#{state.id}']" for state in scxmlJson.states)
-
- toReturn += "var instances = {};\n"
- toReturn += stateClassStrings.join("\n")
- toReturn += "var stateClassNameList = #{initializer.arrayToIdentifierListString stateClassNameList};"
- toReturn += """
- return function(state,eventNames,evaluator){
- var toReturn = [];
-
- if(eventNames.length){
- //named events
- for(var j = 0; j < eventNames.length; j++){
- var eventName = eventNames[j];
-
- var method = stateClassNameList[state.documentOrder][eventName];
- if(method){
- var transitions = method(evaluator);
- if(transitions){
- toReturn = toReturn.concat(transitions);
- }
- }
- }
-
- //wildcard event
- toReturn = toReturn.concat(stateClassNameList[state.documentOrder]['#{WILDCARD_EVENT_NAME}'](evaluator) || []);
- }
-
- //default events
- toReturn = toReturn.concat(stateClassNameList[state.documentOrder]['#{DEFAULT_EVENT_NAME}'](evaluator) || []);
- return toReturn;
- };
- """
-
- toReturn = initializer.genOuterInitializerStr scxmlJson,toReturn
-
- toReturn = if asyncModuleDef then "define(function(){return #{toReturn}});" else toReturn
-
- if beautify then js_beautify toReturn else toReturn
@@ -1,58 +0,0 @@
-# Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-define ->
- transitionToVarLabel : (transition) -> "$#{transition.id}"
-
- genOuterInitializerStr : (scxmlJson,innerFnStr) ->
- toReturn = """
- function(transitions,eventMap){
- var
- """
-
- for i in [0...scxmlJson.transitions.length]
- toReturn += "#{@transitionToVarLabel scxmlJson.transitions[i]} = transitions[#{i}]#{if i < (scxmlJson.transitions.length-1) then ',' else ''}"
-
- toReturn += ";\n"
-
- toReturn += """
- #{innerFnStr}
- };
- """
-
- transitionFilterString : """
- //filter transitions based on condition
- var toReturn = [];
- for(var i=0; i < transitions.length; i++){
- var transition = transitions[i];
- if(!transition.cond || evaluator(transition)){
- toReturn.push(transition);
- }
- }
- return toReturn;
- """
-
- arrayToIdentifierListString : (transitions) ->
- toReturn = "["
-
- #you get the idea here. these strings will show up as identifiers in the generated code
- #the identifiers get set up in the outer context (from genOuterInitializerStr), and captured via closure in the inner context
- for i in [0...transitions.length]
- transitionLabel = transitions[i]
- toReturn += transitionLabel
- if i < transitions.length - 1
- toReturn += ","
-
- toReturn += "]"
-
@@ -1,106 +0,0 @@
-# Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-define ["optimization/initializer","lib/beautify"],(initializer,js_beautify)->
- tableToString = (table) ->
- toReturn = "[\n"
-
- for i in [0...table.length]
- toReturn += "\t["
-
- for j in [0...table[i].length]
-
- if table[i][j].length > 0
- toReturn += "["
- for k in [0...table[i][j].length]
- transitionLabel = table[i][j][k]
- toReturn += transitionLabel
-
- if k < table[i][j].length - 1
- toReturn += ","
- toReturn += "]"
- else
- toReturn += "null"
-
- if j < table[i].length - 1
- toReturn += ","
-
- toReturn += "]"
- if i < table.length - 1 then toReturn += ","
- toReturn += "\n"
-
- toReturn += "]"
- return toReturn
-
- defaultTableToString = (table) ->
- toReturn = "[\n"
-
- for i in [0...table.length]
- if table[i].length
- toReturn += "\t["
-
- for j in [0...table[i].length]
-
- transitionLabel = table[i][j]
- toReturn += transitionLabel
-
- if j < table[i].length - 1
- toReturn += ","
-
- toReturn += "]"
- else
- toReturn += "null"
-
- if i < table.length - 1 then toReturn += ","
- toReturn += "\n"
-
- toReturn += "]"
- return toReturn
-
- (scxmlJson,beautify=true,asyncModuleDef=true) ->
- #NOTE: scxmlJson.events will not contain wildcard ("*") event,
- #and will normalize events like "foo.bat.*" to "foo.bat"
- stateTransitionTable = (((initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and eventName in transition.events) for eventName of scxmlJson.events ) for state in scxmlJson.states)
- wildcardTransitionsForStates = ((initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and "*" in transition.events) for state in scxmlJson.states)
- defaultTransitionsForStates = ((initializer.transitionToVarLabel transition for transition in state.transitions when not transition.events) for state in scxmlJson.states)
- toReturn = initializer.genOuterInitializerStr scxmlJson,"""
- var stateTransitionTable = #{tableToString stateTransitionTable},
- wildcardTransitionTable = #{defaultTableToString wildcardTransitionsForStates},
- defaultTransitionTable = #{defaultTableToString defaultTransitionsForStates};
- return function(state,eventNames,evaluator){
- var transitions = [];
-
- if(eventNames.length){
- for(var j = 0; j < eventNames.length; j++){
- var eventName = eventNames[j];
- var enumeratedEvent = eventMap[eventName];
- if(enumeratedEvent){
- var eventId = enumeratedEvent.documentOrder;
-
- transitions = transitions.concat(stateTransitionTable[state.documentOrder][eventId] || []);
- }
- }
-
- transitions = transitions.concat(wildcardTransitionTable[state.documentOrder] || []);
- }
- //default events
- transitions = transitions.concat(defaultTransitionTable[state.documentOrder] || []);
-
- #{initializer.transitionFilterString}
- };
- """
-
- toReturn = if asyncModuleDef then "define(function(){return #{toReturn}});" else toReturn
-
- if beautify then js_beautify toReturn else toReturn
@@ -1,90 +0,0 @@
-# Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-define ["optimization/initializer","lib/beautify"],(initializer,js_beautify)->
-
- (scxmlJson,beautify=true,asyncModuleDef=true) ->
- toReturn = """
- return function(state,eventNames,evaluator){
- var transitions=[];
-
- switch(state.id){
- """
-
- for state in scxmlJson.states when state.transitions.length
-
- wildcardTransitions = (initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and "*" in transition.events)
- defaultTransitions= (initializer.transitionToVarLabel transition for transition in state.transitions when not transition.events)
-
- toReturn += """
- case "#{state.id}":
- """
-
-
- if defaultTransitions.length
- toReturn +=
- """
- //default transitions
- transitions = transitions.concat(#{initializer.arrayToIdentifierListString defaultTransitions});
- """
-
- if wildcardTransitions.length
- toReturn +=
- """
- if(eventNames.length){
- //wildcard event
- transitions = transitions.concat(#{initializer.arrayToIdentifierListString wildcardTransitions});
- }
- """
-
- toReturn += """
- for(var j = 0; j < eventNames.length; j++){
- var eventName = eventNames[j];
-
- switch(eventName){
- """
-
- for own eventName of scxmlJson.events
- #NOTE: scxmlJson.events will not contain wildcard ("*") event,
- #and will normalize events like "foo.bat.*" to "foo.bat"
- transitionsForEvent = (initializer.transitionToVarLabel transition for transition in state.transitions when transition.events and eventName in transition.events)
- if transitionsForEvent.length
- toReturn += """
- case "#{eventName}":
- transitions = transitions.concat(#{initializer.arrayToIdentifierListString transitionsForEvent});
- break;
- """
-
- toReturn += """
- default: break;
- }
- }
- break;
- """
-
- toReturn += """
-
- //should throw an error here for unrecognized state
- default : break;
- }
-
- #{initializer.transitionFilterString}
- };
- """
-
- toReturn = initializer.genOuterInitializerStr scxmlJson,toReturn
-
- toReturn = if asyncModuleDef then "define(function(){return #{toReturn}});" else toReturn
-
- if beautify then js_beautify toReturn else toReturn
Oops, something went wrong.

0 comments on commit cc6ad9d

Please sign in to comment.