public IOperand CompileAsOperand([NotNull] IRoutineBuilder rb, [NotNull] ZilObject expr, [NotNull] ISourceLine src, [CanBeNull] IVariable suggestion = null) { expr = expr.Unwrap(Context); var constant = CompileConstant(expr, AmbiguousConstantMode.Pessimistic); if (constant != null) { return(constant); } switch (expr.StdTypeAtom) { case StdAtom.FORM: return(CompileForm(rb, (ZilForm)expr, true, suggestion ?? rb.Stack)); case StdAtom.ATOM: var atom = (ZilAtom)expr; if (Globals.ContainsKey(atom)) { Context.HandleError(new CompilerError(src, CompilerMessages.Bare_Atom_0_Interpreted_As_Global_Variable_Index, atom)); return(Globals[atom].Indirect); } if (SoftGlobals.ContainsKey(atom)) { Context.HandleError(new CompilerError( expr.SourceLine ?? src, CompilerMessages.Soft_Variable_0_May_Not_Be_Used_Here, atom)); } else { Context.HandleError(new CompilerError( expr.SourceLine ?? src, CompilerMessages.Bare_Atom_0_Used_As_Operand_Is_Not_A_Global_Variable, atom)); } return(Game.Zero); default: Context.HandleError(new CompilerError( expr.SourceLine ?? src, CompilerMessages.Expressions_Of_This_Type_Cannot_Be_Compiled)); return(Game.Zero); } }
bool VariableNameInUse([NotNull] ZilAtom atom) { return(Locals.ContainsKey(atom) || TempLocalNames.Contains(atom) || Globals.ContainsKey(atom) || SoftGlobals.ContainsKey(atom) || Constants.ContainsKey(atom) || Objects.ContainsKey(atom) || Routines.ContainsKey(atom)); }