public static ZilObject UNASSIGN(Context ctx, [NotNull] ZilAtom atom, [NotNull] LocalEnvironment env) { if (atom == null) { throw new ArgumentNullException(nameof(atom)); } if (env == null) { throw new ArgumentNullException(nameof(env)); } env.SetLocalVal(atom, null); return(atom); }
public static ZilObject VALUE(Context ctx, [NotNull] ZilAtom atom, [NotNull] LocalEnvironment env) { var result = env.GetLocalVal(atom) ?? ctx.GetGlobalVal(atom); if (result == null) { throw new InterpreterError( InterpreterMessages._0_Atom_1_Has_No_2_Value, "VALUE", atom.ToStringContext(ctx, false), "local or global"); } return(result); }
/// <summary> /// Creates a new environment, optionally inheriting bindings from a parent environment. /// </summary> /// <param name="ctx">The context.</param> /// <param name="parent">The parent environment, or <see langword="null"/> to not inherit any bindings.</param> /// <remarks>Changes made to bindings in the parent environment will be visible in the new environment, /// unless overridden by bindings created in the new environment with <see cref="Rebind"/>.</remarks> public LocalEnvironment([NotNull] Context ctx, [CanBeNull] LocalEnvironment parent = null) { this.ctx = ctx ?? throw new ArgumentNullException(nameof(ctx)); Parent = parent; }
public static ZilResult EVAL([NotNull] Context ctx, [NotNull] ZilObject value, [NotNull] LocalEnvironment env) { return(value.Eval(ctx, env)); }
public static ZilObject BOUND_P([NotNull] Context ctx, [NotNull] ZilAtom atom, [NotNull] LocalEnvironment env) { return(env.IsLocalBound(atom) ? ctx.TRUE : ctx.FALSE); }
public static ZilObject ASSIGNED_P([NotNull] Context ctx, [NotNull] ZilAtom atom, [NotNull] LocalEnvironment env) { return(env.GetLocalVal(atom) != null ? ctx.TRUE : ctx.FALSE); }
public static ZilObject SET(Context ctx, [NotNull] ZilAtom atom, ZilObject value, [NotNull] LocalEnvironment env) { env.SetLocalVal(atom, value); return(value); }