| 460 | } |
| 461 | |
| 462 | function doLoadEnvironment(data, scope) { |
| 463 | var cx = infer.cx(), server = cx.parent |
| 464 | |
| 465 | infer.addOrigin(cx.curOrigin = data["!name"] || "env#" + cx.origins.length); |
| 466 | cx.localDefs = cx.definitions[cx.curOrigin] = Object.create(null); |
| 467 | |
| 468 | if (server) server.signal("preLoadDef", data) |
| 469 | |
| 470 | passOne(scope, data); |
| 471 | |
| 472 | var def = data["!define"]; |
| 473 | if (def) { |
| 474 | for (var name in def) { |
| 475 | var spec = def[name]; |
| 476 | cx.localDefs[name] = typeof spec == "string" ? parsePath(spec) : passOne(null, spec, name); |
| 477 | } |
| 478 | for (var name in def) { |
| 479 | var spec = def[name]; |
| 480 | if (typeof spec != "string") passTwo(cx.localDefs[name], def[name], name); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | passTwo(scope, data); |
| 485 | |
| 486 | if (server) server.signal("postLoadDef", data) |
| 487 | |
| 488 | cx.curOrigin = cx.localDefs = null; |
| 489 | } |
| 490 | |
| 491 | exports.load = function(data, scope) { |
| 492 | if (!scope) scope = infer.cx().topScope; |