Ejemplo n.º 1
0
        private static string GetVariableKindText(VariableKind kind)
        {
            switch (kind)
            {
            case VariableKind.Property:
                return("property");

            case VariableKind.Method:
                return("method");

            case VariableKind.Field:
                return("field");

            case VariableKind.Local:
                return("local");

            case VariableKind.Unknown:
                return("unknown");

            default:
                throw new InvalidOperationException("Invalid SymbolKind: " + kind.ToString());
            }
        }
Ejemplo n.º 2
0
 private static string GetVariableKindText(VariableKind kind)
 {
     switch (kind)
     {
         case VariableKind.Property:
             return "property";
         case VariableKind.Method:
             return "method";
         case VariableKind.Field:
             return "field";
         case VariableKind.Local:
             return "local";
         case VariableKind.Unknown:
             return "unknown";
         default:
             throw new InvalidOperationException("Invalid SymbolKind: " + kind.ToString());
     }
 }
Ejemplo n.º 3
0
        internal Slot CreateSlot(CodeGen cg)
        {
            switch (_kind)
            {
            case VariableKind.Local:
                if (_storage == null)
                {
                    // Fall back on a runtime lookup if this variable does not have storage associated with it
                    // (e.g. if the variable belongs to a block in interpreted mode).
                    return(new LocalNamedFrameSlot(cg.ContextSlot, _name));
                }
                else
                {
                    return(CreateSlotForVariable(cg));
                }

            case VariableKind.Parameter:
                if (_lift)
                {
                    if (_storage == null)
                    {
                        return(new LocalNamedFrameSlot(cg.ContextSlot, _name));
                    }
                    else
                    {
                        return(CreateSlotForVariable(cg));
                    }
                }
                else
                {
                    //Debug.Assert(cg.Allocator.ActiveScope == _block);
                    return(MarkLocal(GetArgumentSlot(cg)));
                }

            case VariableKind.Global:
                if (_storage == null)
                {
                    return(new NamedFrameSlot(cg.ContextSlot, _name));
                }
                else
                {
                    // Globals are accessed via context slot
                    return(_storage.CreateSlot(cg.ContextSlot));
                }

            case VariableKind.Temporary:
                return(cg.GetNamedLocal(_type, SymbolTable.IdToString(_name)));

            case VariableKind.GeneratorTemporary:
                if (!cg.IsGenerator)
                {
                    goto case VariableKind.Temporary;
                }

                // Allocate in environment if emitting generator.
                // This must be done here for now because the environment
                // allocation, which is generally done in Allocate(),
                // is done in the context of the outer generator codegen,
                // which is not marked IsGenerator so the generator temps
                // would go onto CLR stack rather than environment.
                // TODO: Fix this once we have lifetime analysis in place.
                _storage = _block.EnvironmentFactory.MakeEnvironmentReference(_name, _type);
                return(CreateSlotForVariable(cg));
            }

            Debug.Assert(false, "Unexpected variable kind: " + _kind.ToString());
            return(null);
        }