Skip to content
Dethe Elza edited this page Nov 10, 2015 · 5 revisions

Below are the main steps taken to run a script now. Some of the steps should be indented and some are choices (either wb-step or wb-expression) rather than sequential. I'm still figuring out how to represent all that better.

[Update 2015-11-09] When my current branch is pulled in there are some significant changes, reflected below. First, there is no "context" object to pass around. Calling run() on a block calls the function set up in the HTML and defined in runtime.js with the block itself as this. Blocks can call their children for values, steps to iterate, etc. Context blocks are expected to fetch their children to run, but any block not marked with the attribute specialform will be passed in values as arguments to the runtime function. We don't do this for special forms because they need to be able to selectively not run their arguments (for instance, to implement short-circuit evaluation). Steps, Contexts, and Expressions now all inherit from BlockProto (earlier Expression blocks did not) and some of the methods which had divergent implementations have been refactored to use the same method.

  1. Click "Run"
  2. startScript()
  3. preload()
  4. runScript()
  5. runtime.startEventLoop()
  6. for each top-level block in workspace:
  7. block.run()
  8. BlockProto.run() -> this.fn([value1], [value2], ...);
  9. BlockProto.gatherValues() -> for each value (wb-value[type], wb-value[value], wb-row) in header return getValue(scope)
  10. ExpressionProto.getValue(scope) -> return [this.getAttribute('value') OR BlockProto.gatherValues.call(this, scope)
  11. RowProto.getValue(scope) -> [Can return a single item, an array, or null: should always return an array for simplicity] for item in `return this.children(wb-value:not(.hide), wb-local): return item.getValue()
  12. LocalProto.getValue(scope) -> return this.find('wb-value).getValue(scope);`
  13. ValueProto.getValue(scope) -> 19. if has child wb-expression as block: return block.run() 20. else 21. primaryType = this.child(input, select).getAttribute('type').split(',')[0] 22. value = this.child(input, select).value OR this.getAttribute('value') 23. return convertprimaryType if convert[primaryType]ORreturn value`