Beispiel #1
0
        /// <summary>
        /// Set the value of the given global variable.
        /// </summary>
        /// <param name="name">Name of the global variable.</param>
        /// <param name="value">New value of the global variable.</param>
        /// <returns>True if the variable exists, otherwise false.</returns>
        public bool SetGlobal(string name, object value)
        {
            GlobalVariableBinding binding = this.GlobalScope.GetGlobalVariableBinding(name);

            if (binding == null)
            {
                return(false);
            }
            binding.Value = value;
            return(true);
        }
Beispiel #2
0
        public bool TrySetGlobal(Symbol name, object value)
        {
            GlobalVariableBinding binding = this.Runtime.GlobalScope.GetGlobalVariableBinding(name);

            if ((binding == null) || binding.IsConstantBinding)
            {
                return(false);
            }
            binding.Value = value;
            return(true);
        }
Beispiel #3
0
        public static GlobalVariableBinding AddGlobalVariableBinding(SmalltalkRuntime runtime, SmalltalkNameScope scope, string name)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }
            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            Symbol symbol = runtime.GetSymbol(name);

            GlobalVariableBinding binding = new GlobalVariableBinding(symbol);

            scope.GlobalVariables.Add(binding);
            return(binding);
        }
Beispiel #4
0
 void ISmalltalkNameScopeVisitor.Visit(GlobalVariableBinding binding)
 {
     this.Generators.Add(new GlobalVariableGenerator(this.Compiler, binding));
 }
 void IInstallerContext.AddGlobalVariableBinding(GlobalVariableBinding binding)
 {
     this.NameScope.GlobalVariables.Add(binding);
 }
 void IDefinitionInstallerContext.AddGlobalVariableBinding(GlobalVariableBinding binding)
 {
     this.NameScope.GlobalVariables.Add(binding);
 }