-
Notifications
You must be signed in to change notification settings - Fork 88
How a script runs
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.
- Click "Run"
startScript()
preload()
runScript()
runtime.startEventLoop()
- for each top-level block in workspace:
block.run()
-
BlockProto.run()
->this.fn([value1], [value2], ...);
-
BlockProto.gatherValues()
-> for each value (wb-value[type], wb-value[value], wb-row) in headerreturn getValue(scope)
-
ExpressionProto.getValue(scope)
->return [this.getAttribute('value')
ORBlockProto.gatherValues.call(this, scope)
-
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() -
LocalProto.getValue(scope)
->return this.find('wb-value
).getValue(scope);` -
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
ORthis.getAttribute('value') 23.
return convertprimaryType if convert[primaryType]OR
return value`