Inheritance: VsaItem, IJSVsaCodeItem, IJSVsaItem
        public IJSVsaItem CreateItem(string name, JSVsaItemType itemType, JSVsaItemFlag itemFlag)
        {
            IJSVsaItem item2;
            if (this.isClosed)
            {
                throw new JSVsaException(JSVsaError.EngineClosed);
            }
            if (this.engine.IsRunning)
            {
                throw new JSVsaException(JSVsaError.EngineRunning);
            }
            this.TryObtainLock();
            try
            {
                if ((itemType != JSVsaItemType.Reference) && !this.engine.IsValidIdentifier(name))
                {
                    throw new JSVsaException(JSVsaError.ItemNameInvalid);
                }
                foreach (object obj2 in this.items)
                {
                    if (((VsaItem) obj2).Name.Equals(name))
                    {
                        throw new JSVsaException(JSVsaError.ItemNameInUse);
                    }
                }
                IJSVsaItem item = null;
                switch (itemType)
                {
                    case JSVsaItemType.Reference:
                        if (itemFlag != JSVsaItemFlag.None)
                        {
                            throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                        }
                        break;

                    case JSVsaItemType.AppGlobal:
                        if (itemFlag != JSVsaItemFlag.None)
                        {
                            throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                        }
                        goto Label_00E3;

                    case JSVsaItemType.Code:
                        if (itemFlag == JSVsaItemFlag.Class)
                        {
                            throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                        }
                        goto Label_010E;

                    default:
                        goto Label_012A;
                }
                item = new VsaReference(this.engine, name);
                goto Label_012A;
            Label_00E3:
                item = new VsaHostObject(this.engine, name, JSVsaItemType.AppGlobal);
                ((VsaHostObject) item).isVisible = true;
                goto Label_012A;
            Label_010E:
                item = new VsaStaticCode(this.engine, name, itemFlag);
                this.staticCodeBlockCount++;
            Label_012A:
                if (item != null)
                {
                    this.items.Add(item);
                }
                else
                {
                    throw new JSVsaException(JSVsaError.ItemTypeNotSupported);
                }
                this.engine.IsDirty = true;
                item2 = item;
            }
            finally
            {
                this.ReleaseLock();
            }
            return item2;
        }
Exemplo n.º 2
0
 // GetScannerInstance is used by IsValidNamespaceName and IsValidIdentifier to validate names.
 // We return an instance of the scanner only if there is no whitespace in the name text, since
 // we do not want to allow, say, "not. valid" to be a valid namespace name even though that
 // would produce a valid sequence of tokens.
 private JSScanner GetScannerInstance(string name){
   // make sure there's no whitespace in the name (values copied from documentation on String.Trim())
   char[] anyWhiteSpace = {
     (char)0x0009, (char)0x000A, (char)0x000B, (char)0x000C, (char)0x000D, (char)0x0020, (char)0x00A0,
     (char)0x2000, (char)0x2001, (char)0x2002, (char)0x2003, (char)0x2004, (char)0x2005, (char)0x2006,
     (char)0x2007, (char)0x2008, (char)0x2009, (char)0x200A, (char)0x200B, (char)0x3000, (char)0xFEFF
   };
   if (name == null || name.IndexOfAny(anyWhiteSpace) > -1)
     return null;
   // Create a code item whose source is the given text
   VsaItem item = new VsaStaticCode(this, "itemName", VsaItemFlag.None);
   Context context = new Context(new DocumentContext(item), name);
   context.errorReported = -1;
   JSScanner scanner = new JSScanner(); //Use this constructor to avoid allocating a Globals instance
   scanner.SetSource(context);
   return scanner;
 }
Exemplo n.º 3
0
        public IJSVsaItem CreateItem(string name, JSVsaItemType itemType, JSVsaItemFlag itemFlag)
        {
            IJSVsaItem item2;

            if (this.isClosed)
            {
                throw new JSVsaException(JSVsaError.EngineClosed);
            }
            if (this.engine.IsRunning)
            {
                throw new JSVsaException(JSVsaError.EngineRunning);
            }
            this.TryObtainLock();
            try
            {
                if ((itemType != JSVsaItemType.Reference) && !this.engine.IsValidIdentifier(name))
                {
                    throw new JSVsaException(JSVsaError.ItemNameInvalid);
                }
                foreach (object obj2 in this.items)
                {
                    if (((VsaItem)obj2).Name.Equals(name))
                    {
                        throw new JSVsaException(JSVsaError.ItemNameInUse);
                    }
                }
                IJSVsaItem item = null;
                switch (itemType)
                {
                case JSVsaItemType.Reference:
                    if (itemFlag != JSVsaItemFlag.None)
                    {
                        throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                    }
                    break;

                case JSVsaItemType.AppGlobal:
                    if (itemFlag != JSVsaItemFlag.None)
                    {
                        throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                    }
                    goto Label_00E3;

                case JSVsaItemType.Code:
                    if (itemFlag == JSVsaItemFlag.Class)
                    {
                        throw new JSVsaException(JSVsaError.ItemFlagNotSupported);
                    }
                    goto Label_010E;

                default:
                    goto Label_012A;
                }
                item = new VsaReference(this.engine, name);
                goto Label_012A;
Label_00E3:
                item = new VsaHostObject(this.engine, name, JSVsaItemType.AppGlobal);
                ((VsaHostObject)item).isVisible = true;
                goto Label_012A;
Label_010E:
                item = new VsaStaticCode(this.engine, name, itemFlag);
                this.staticCodeBlockCount++;
Label_012A:
                if (item != null)
                {
                    this.items.Add(item);
                }
                else
                {
                    throw new JSVsaException(JSVsaError.ItemTypeNotSupported);
                }
                this.engine.IsDirty = true;
                item2 = item;
            }
            finally
            {
                this.ReleaseLock();
            }
            return(item2);
        }
Exemplo n.º 4
0
        public virtual IVsaItem CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag)
        {
            if (this.isClosed)
            {
                throw new VsaException(VsaError.EngineClosed);
            }
            if (this.engine.IsRunning)
            {
                throw new VsaException(VsaError.EngineRunning);
            }
            this.TryObtainLock();
            try{
                // The name must be valid for all items except reference items (in which case we don't care)
                if (itemType != VsaItemType.Reference && !this.engine.IsValidIdentifier(name))
                {
                    throw new VsaException(VsaError.ItemNameInvalid);
                }
                // Make sure the name isn't already in use
                foreach (Object vsaItem in this.items)
                {
                    if (((VsaItem)vsaItem).Name.Equals(name))
                    {
                        throw new VsaException(VsaError.ItemNameInUse);
                    }
                }
                IVsaItem item = null;
                switch (itemType)
                {
                // IVsaReference
                case VsaItemType.Reference:
                    if (itemFlag != VsaItemFlag.None)
                    {
                        throw new VsaException(VsaError.ItemFlagNotSupported);
                    }
                    // create a wrapper around an assembly
                    item = new VsaReference((VsaEngine)this.engine, name);
                    break;

                //IVsaGlobalItem
                case VsaItemType.AppGlobal:
                    if (itemFlag != VsaItemFlag.None)
                    {
                        throw new VsaException(VsaError.ItemFlagNotSupported);
                    }
                    item = new VsaHostObject((VsaEngine)this.engine, name, VsaItemType.AppGlobal);
                    ((VsaHostObject)item).isVisible = true;
                    break;

                // IVsaCodeItem
                case VsaItemType.Code:
                    if (itemFlag == VsaItemFlag.Class)
                    {
                        throw new VsaException(VsaError.ItemFlagNotSupported);
                    }
                    item = new VsaStaticCode((VsaEngine)this.engine, name, itemFlag);
                    this.staticCodeBlockCount++;
                    break;
                }
                if (item != null)
                {
                    this.items.Add(item);
                }
                else
                {
                    throw new VsaException(VsaError.ItemTypeNotSupported);
                }
                ((VsaEngine)this.engine).IsDirty = true;
                return(item);
            }finally{
                this.ReleaseLock();
            }
        }
Exemplo n.º 5
0
    public virtual IVsaItem CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag){
      if (this.isClosed)
        throw new VsaException(VsaError.EngineClosed);
      if (this.engine.IsRunning)
        throw new VsaException(VsaError.EngineRunning);
      this.TryObtainLock();
      try{
        // The name must be valid for all items except reference items (in which case we don't care)
        if (itemType != VsaItemType.Reference && !this.engine.IsValidIdentifier(name))
          throw new VsaException(VsaError.ItemNameInvalid);
        // Make sure the name isn't already in use
        foreach (Object vsaItem in this.items){
          if (((VsaItem)vsaItem).Name.Equals(name))
            throw new VsaException(VsaError.ItemNameInUse);
        }
        IVsaItem item = null;
        switch (itemType){
          // IVsaReference
          case VsaItemType.Reference:
            if (itemFlag != VsaItemFlag.None)
              throw new VsaException(VsaError.ItemFlagNotSupported);
            // create a wrapper around an assembly
            item = new VsaReference((VsaEngine)this.engine, name);
            break;

          //IVsaGlobalItem
          case VsaItemType.AppGlobal:
            if (itemFlag != VsaItemFlag.None)
              throw new VsaException(VsaError.ItemFlagNotSupported);
            item = new VsaHostObject((VsaEngine)this.engine, name, VsaItemType.AppGlobal);
            ((VsaHostObject)item).isVisible = true;
            break;

          // IVsaCodeItem
          case VsaItemType.Code:
            if (itemFlag == VsaItemFlag.Class)
              throw new VsaException(VsaError.ItemFlagNotSupported);
            item = new VsaStaticCode((VsaEngine)this.engine, name, itemFlag);
            this.staticCodeBlockCount++;
            break;
        }
        if (item != null){
          this.items.Add(item);
        }else{
          throw new VsaException(VsaError.ItemTypeNotSupported);
        }
        ((VsaEngine)this.engine).IsDirty = true;
        return item;
      }finally{
        this.ReleaseLock();
      }
    }
 private JSScanner GetScannerInstance(string name)
 {
     char[] anyOf = new char[] { 
         '\t', '\n', '\v', '\f', '\r', ' ', '\x00a0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 
         ' ', ' ', '​', ' ', ''
      };
     if ((name == null) || (name.IndexOfAny(anyOf) > -1))
     {
         return null;
     }
     VsaItem sourceItem = new VsaStaticCode(this, "itemName", JSVsaItemFlag.None);
     Context sourceContext = new Context(new DocumentContext(sourceItem), name) {
         errorReported = -1
     };
     JSScanner scanner = new JSScanner();
     scanner.SetSource(sourceContext);
     return scanner;
 }