Exemple #1
0
 internal void WriteSymbol(JSSymbol symbol, ref mdr.DValue result, ref mdr.CallFrame callFrame)
 {
   switch (symbol.SymbolType)
   {
     case JSSymbol.SymbolTypes.Local:
     case JSSymbol.SymbolTypes.HiddenLocal:
     case JSSymbol.SymbolTypes.Arguments:
       {
         if (symbol.IsParameter)
           if (Arguments != null)
             Arguments.Elements[symbol.ParameterIndex].Set(ref result);
           else
             callFrame.SetArg(symbol.ParameterIndex, ref result);
         else
           SymbolValues[symbol.ValueIndex] = result;
         break;
       }
     case JSSymbol.SymbolTypes.ClosedOnLocal:
     case JSSymbol.SymbolTypes.ParentLocal:
     case JSSymbol.SymbolTypes.Global:
       {
         var pd = GetPropertyDescriptor(symbol);
         pd.Set(Context, ref result);
         break;
       }
     case JSSymbol.SymbolTypes.Unknown:
       {
         var pd = Context.GetPropertyDescriptorByFieldId(symbol.FieldId);
         if (pd.IsUndefined)
           JSRuntime.Instance.GlobalContext.SetFieldByFieldId(symbol.FieldId, ref result);
         else
           pd.Set(Context, ref result);
         break;
       }
     case JSSymbol.SymbolTypes.OuterDuplicate:
       WriteSymbol(symbol.ResolvedSymbol, ref result, ref callFrame);
       break;
     default:
       Trace.Fail("Could not interpret symbol {0} with type {1}", symbol.Name, symbol.SymbolType);
       break;
   }
 }