class EcmaScriptDataModel implements DataModel {

    @Override
    public int createScope(final Scope scope) {
        if (scope == null) {
            return createScope();
        }
        if (topmostScope == null) {
            // create an initial scope if none present
            final Context context = getContext();
            rootScope = context.initStandardObjects();
            topmostScope = rootScope;
        }

        // Create the implicit variable as the scriptable on the scope stack.
        final Context context = Context.getCurrentContext();
        final Scriptable newScope = context.newObject(topmostScope);
        newScope.setPrototype(topmostScope);
        newScope.setParentScope(null);
        
        // Create an implicit variable to access this scope if no anonymous
        // scope
        if (scope != Scope.ANONYMOUS) {
            ScriptableObject.putProperty(newScope, scope.getName(), newScope);
        }

        // Remember the new scope
        topmostScope = newScope;
        scopes.put(topmostScope, scope);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("created scope '" + scope.name() + "'");
        }
        return NO_ERROR;
    }

    public  EcmaScriptDataModel();

}