Skip to content

Commit 3757a76

Browse files
committed
Implement DefineConstant for Context
1 parent c424597 commit 3757a76

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

NiL.JS/Core/Context.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ internal Context GetRunningContextFor(Function function, out Context prevContext
313313
return null;
314314
}
315315

316-
internal virtual void ReplaceVariableInstance(string name, JSValue instance)
316+
public virtual JSValue DefineConstant(string name, JSValue value, bool deletable = false)
317317
{
318-
if (_variables != null && _variables.ContainsKey(name))
319-
_variables[name] = instance;
320-
else
321-
_parent?.ReplaceVariableInstance(name, instance);
318+
var v = DefineVariable(name, deletable);
319+
v.Assign(value);
320+
v._attributes |= JSValueAttributesInternal.ReadOnly;
321+
return v;
322322
}
323323

324324
public virtual JSValue DefineVariable(string name, bool deletable = false)

0 commit comments

Comments
 (0)