 # Find the correct function across browsers
 requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
   window.webkitRequestAnimationFrame || window.msRequestAnimationFrame
+
+# Converts pin default values (with code as strings) to compiled form with code as functions.
+# Leaves non-code values as they were
+compilePinDefs = (pinDefs, evaluator) ->
+  return GE.mapObject pinDefs, (value, key) ->
+    compiledPinParams = {}
+    try
+      for pinParamKey, pinParamValue of value
+        compiledPinParams[pinParamKey] = switch pinParamKey
+          when "default" then GE.compileExpression(pinParamValue, evaluator)
+          else pinParamValue
+      return compiledPinParams
+    catch compilationError
+      throw new Error("Error compiling pin defaults for '#{key}'. #{compilationError}")
 
 # Converts input processors (with code as strings) to compiled form with code as functions.
 # Leaves non-code values as they were

      for processorKey, processorValue of value
        compiledProcessor[processorKey] = switch processorKey
          when "update" then GE.compileUpdate(processorValue, evaluator)
          else processorValue
      return compiledProcessor
    catch compilationError

      throw new Error("Error compiling transformer '#{key}'. #{compilationError}")
  transformersContext.transformers = compiledTransformers
  return compiledTransformers

# Converts board expressions (with code as strings) to compiled form with code as functions.
# Leaves non-code values as they were.
compileBoard = (board, evaluator) ->
  return GE.mapObject board, (value, key) ->
    switch key
      when "emitter" then GE.mapObject(value, (expression, dest) -> GE.compileExpression(expression, evaluator))
      when "pins" 
        in: if value.in then GE.mapObject(value.in, (expression, pinName) -> GE.compileExpression(expression, evaluator)) else {}
        out: if value.out then GE.mapObject(value.out, (expression, dest) -> GE.compileExpression(expression, evaluator)) else {}
      when "children" then _.map(value, (child) -> compileBoard(child, evaluator))
      else value

destroyIo = (currentIo) ->
  for ioName, io of currentIo
