Пример #1
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var fallthroughBlock = context.FallThroughBlock;

            var op1 = importer.PopExpression();

            var targets   = instruction.Operand as Instruction[];
            var jumpTable = new List <string>(targets?.Length ?? 0);

            if (targets != null)
            {
                foreach (var target in targets)
                {
                    var targetBlock = importer.BasicBlocks[(int)target.Offset];
                    jumpTable.Add(targetBlock.Label);
                    importer.ImportFallThrough(targetBlock);
                }
            }

            var switchNode = new SwitchEntry(op1, jumpTable);

            importer.ImportAppendTree(switchNode);

            // TODO: Can this ever be null?
            if (fallthroughBlock != null)
            {
                importer.ImportFallThrough(fallthroughBlock);
            }

            context.StopImporting = true;
        }
Пример #2
0
 public void Visit(SwitchEntry entry)
 {
     _indent++;
     entry.Op1.Accept(this);
     _indent--;
     Print($"SWITCH {entry.JumpTable}");
 }
Пример #3
0
        private void PlayNext()
        {
            bool fromBelow = !(_lastClipList != null && _nextClipList != null && _nextClipList.Threshhold < _lastClipList.Threshhold);

            _currentClipList         = _nextClipList.PlayAudioClipList;
            _currentClipList.Shedule = null;
            _currentClipList.Play(true, fromBelow);
            _nextClipList = null;
        }
Пример #4
0
        public void OnChange(IScriptableVariable <float> variable)
        {
            var nextClipList = GetNext();

            _nextClipList = nextClipList;
            if (_nextClipList != null && _nextClipList.PlayAudioClipList == _currentClipList)
            {
                if (_currentClipList != null)
                {
                    _currentClipList.Shedule = null;
                }
                return;
            }

            if (_currentClipList != null)
            {
                if (_nextClipList == null)
                {
                    StartCoroutine(Stop());
                }
                else if (_nextClipList.Transition == TransitionType.Cut)
                {
                    _currentClipList.Stop();
                    PlayNext();
                }
                else if (_nextClipList.Transition == TransitionType.Transition)
                {
                    Debug.Log(_currentClipList);
                    Debug.Log(_currentClipList.CurrentTime);
                    var position = _currentClipList.CurrentTime;
                    _currentClipList.FadeOut(_transitionDuration);
                    PlayNext();
                    position %= _currentClipList.Length;
                    _currentClipList.FadeIn(_transitionDuration, position);
                }
                else
                {
                    _currentClipList.Shedule = this;
                }
            }
            else
            {
                PlayNext();
            }

            _lastClipList = nextClipList;
        }
Пример #5
0
				internal void Read(ushort pc, BigEndianBinaryReader br, ClassFile classFile)
				{
					this.pc = pc;
					ByteCode bc = (ByteCode)br.ReadByte();
					switch(ByteCodeMetaData.GetMode(bc))
					{
						case ByteCodeMode.Simple:
							break;
						case ByteCodeMode.Constant_1:
							arg1 = br.ReadByte();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							break;
						case ByteCodeMode.Local_1:
							arg1 = br.ReadByte();
							break;
						case ByteCodeMode.Constant_2:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							break;
						case ByteCodeMode.Branch_2:
							arg1 = br.ReadInt16();
							break;
						case ByteCodeMode.Branch_4:
							arg1 = br.ReadInt32();
							break;
						case ByteCodeMode.Constant_2_1_1:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							arg2 = br.ReadByte();
							if(br.ReadByte() != 0)
							{
								throw new ClassFormatError("invokeinterface filler must be zero");
							}
							break;
						case ByteCodeMode.Immediate_1:
							arg1 = br.ReadSByte();
							break;
						case ByteCodeMode.Immediate_2:
							arg1 = br.ReadInt16();
							break;
						case ByteCodeMode.Local_1_Immediate_1:
							arg1 = br.ReadByte();
							arg2 = br.ReadSByte();
							break;
						case ByteCodeMode.Constant_2_Immediate_1:
							arg1 = br.ReadUInt16();
							classFile.MarkLinkRequiredConstantPoolItem(arg1);
							arg2 = br.ReadSByte();
							break;
						case ByteCodeMode.Tableswitch:
						{
							// skip the padding
							uint p = pc + 1u;
							uint align = ((p + 3) & 0x7ffffffc) - p;
							br.Skip(align);
							int default_offset = br.ReadInt32();
							this.arg1 = default_offset;
							int low = br.ReadInt32();
							int high = br.ReadInt32();
							if(low > high || high > 16384L + low)
							{
								throw new ClassFormatError("Incorrect tableswitch");
							}
							SwitchEntry[] entries = new SwitchEntry[high - low + 1];
							for(int i = low; i < high; i++)
							{
								entries[i - low].value = i;
								entries[i - low].target = br.ReadInt32();
							}
							// do the last entry outside the loop, to avoid overflowing "i", if high == int.MaxValue
							entries[high - low].value = high;
							entries[high - low].target = br.ReadInt32();
							this.switch_entries = entries;
							break;
						}
						case ByteCodeMode.Lookupswitch:
						{
							// skip the padding
							uint p = pc + 1u;
							uint align = ((p + 3) & 0x7ffffffc) - p;
							br.Skip(align);
							int default_offset = br.ReadInt32();
							this.arg1 = default_offset;
							int count = br.ReadInt32();
							if(count < 0 || count > 16384)
							{
								throw new ClassFormatError("Incorrect lookupswitch");
							}
							SwitchEntry[] entries = new SwitchEntry[count];
							for(int i = 0; i < count; i++)
							{
								entries[i].value = br.ReadInt32();
								entries[i].target = br.ReadInt32();
							}
							this.switch_entries = entries;
							break;
						}
						case ByteCodeMode.WidePrefix:
							bc = (ByteCode)br.ReadByte();
							// NOTE the PC of a wide instruction is actually the PC of the
							// wide prefix, not the following instruction (vmspec 4.9.2)
						switch(ByteCodeMetaData.GetWideMode(bc))
						{
							case ByteCodeModeWide.Local_2:
								arg1 = br.ReadUInt16();
								break;
							case ByteCodeModeWide.Local_2_Immediate_2:
								arg1 = br.ReadUInt16();
								arg2 = br.ReadInt16();
								break;
							default:
								throw new ClassFormatError("Invalid wide prefix on opcode: {0}", bc);
						}
							break;
						default:
							throw new ClassFormatError("Invalid opcode: {0}", bc);
					}
					this.normopcode = ByteCodeMetaData.GetNormalizedByteCode(bc);
					arg1 = ByteCodeMetaData.GetArg(bc, arg1);
				}
Пример #6
0
 public void Visit(SwitchEntry entry)
 {
     _sb.AppendLine($"       ┌──▌  t{entry.Op1.TreeID}");
     _sb.AppendLine($"       switch {entry.JumpTable}");
 }
Пример #7
0
 public void Visit(SwitchEntry entry)
 {
     _genericStackEntryVisitor.Visit <SwitchEntry>(entry);
 }
Пример #8
0
 public void Visit(SwitchEntry entry)
 {
     entry.Op1.Accept(this);
     SetNext(entry);
 }