/// <summary> /// Sets a constant that will be declared in this context. Once a constant is set, it cannot be changed. /// </summary> /// <param name="name">the constant name</param> /// <param name="obj">the object data</param> public void SetConstant(string name, object obj) { ObjectContext context = FindVariableContext(name); if (context == null) { context = FindConstantContext(name); if (context == null) { _constants.Add(name, obj); // since you can set constants only once, we don't need to use the context in which a constant was set } else { throw ThrowHelper.ConstantChange(); } } else { throw ThrowHelper.AlreadyDefinedAsType(name, "variable", "constant"); } }