protected override object DoEvaluate(CodeContext context) { object ret; switch (_variable.Kind) { case Variable.VariableKind.Temporary: case Variable.VariableKind.GeneratorTemporary: if (!context.Scope.TemporaryStorage.TryGetValue(_variable, out ret)) { throw context.LanguageContext.MissingName(_variable.Name); } else { return(ret); } case Variable.VariableKind.Parameter: // This is sort of ugly: parameter variables can be stored either as locals or as temporaries (in case of $argn). if (!context.Scope.TemporaryStorage.TryGetValue(_variable, out ret) || ret == Uninitialized.Instance) { return(RuntimeHelpers.LookupName(context, _variable.Name)); } else { return(ret); } case Variable.VariableKind.Global: return(RuntimeHelpers.LookupGlobalName(context, _variable.Name)); default: if (!context.LanguageContext.TryLookupName(context, _variable.Name, out ret)) { throw context.LanguageContext.MissingName(_variable.Name); } else if (ret == Uninitialized.Instance) { RuntimeHelpers.ThrowUnboundLocalError(_variable.Name); return(null); } else { return(ret); } } }