public static object SetName(Scriptable bound, object value, Context cx, Scriptable scope, string id)
{
if (bound != null)
{
// TODO: we used to special-case XMLObject here, but putProperty
// seems to work for E4X and it's better to optimize the common case
ScriptableObject.PutProperty(bound, id, value);
}
else
{
// "newname = 7;", where 'newname' has not yet
// been defined, creates a new property in the
// top scope unless strict mode is specified.
if (cx.HasFeature(Context.FEATURE_STRICT_MODE) || cx.HasFeature(Context.FEATURE_STRICT_VARS))
{
Context.ReportWarning(ScriptRuntime.GetMessage1("msg.assn.create.strict", id));
}
// Find the top scope by walking up the scope chain.
bound = ScriptableObject.GetTopLevelScope(scope);
if (cx.useDynamicScope)
{
bound = CheckDynamicScope(cx.topCallScope, bound);
}
bound.Put(id, bound, value);
}
return value;
}