Esempio n. 1
0
        private MessageWindow(AsmValueSource messageChanel, AsmValueSource messageId,
                              AsmValueSource x = null, AsmValueSource y = null,
                              AsmValueSource firstAnswerLine   = null, AsmValueSource lastAnswerLine   = null,
                              AsmValueSource defaultAnswerLine = null, AsmValueSource cancelAnswerLine = null)
        {
            _messageChanel = messageChanel;
            _messageId     = messageId;

            if (x != null && y != null)
            {
                _x        = x;
                _y        = y;
                IsMovable = true;
                IsDynamic = IsDynamic || (x.Type != AsmValueSourceType.Static || y.Type != AsmValueSourceType.Static);
            }

            if (firstAnswerLine != null && lastAnswerLine != null && defaultAnswerLine != null && cancelAnswerLine != null)
            {
                _firstAnswerLine   = firstAnswerLine;
                _lastAnswerLine    = lastAnswerLine;
                _defaultAnswerLine = defaultAnswerLine;
                _cancelAnswerLine  = cancelAnswerLine;
                IsDynamic          = IsDynamic || (
                    firstAnswerLine.Type != AsmValueSourceType.Static ||
                    lastAnswerLine.Type != AsmValueSourceType.Static ||
                    defaultAnswerLine.Type != AsmValueSourceType.Static ||
                    cancelAnswerLine.Type != AsmValueSourceType.Static);
                IsQuestion = true;
            }
        }
Esempio n. 2
0
        private void CreateExternalBindings()
        {
            foreach (AsmEvent evt in _scripts.GetOrderedModules().SelectMany(module => module.GetOrderedEvents()))
            {
                for (int i = 0; i < evt.Count; i++)
                {
                    JsmOperation operation = evt[i];
                    switch (operation.Command)
                    {
                    case JsmCommand.REQ:
                    case JsmCommand.REQEW:
                    case JsmCommand.REQSW:
                    {
                        AsmSegment                source           = evt.Segments.GetSegmentByOffset(i);
                        AsmValueSource            labelTargetEvent = AsmValueSource.Create(evt, i - 1);
                        AsmAbsoluteRequestBinding binding          = new AsmAbsoluteRequestBinding(source, i - source.Offset, operation.Argument, labelTargetEvent);
                        source.OutputBindings.Add(binding);
                        AsmSegment[] targets = binding.ResolveTargets();
                        if (targets != null)
                        {
                            foreach (AsmSegment target in targets)
                            {
                                target.InputBindings.Add(binding);
                            }
                        }
                        break;
                    }

                    case JsmCommand.PREQ:
                    case JsmCommand.PREQEW:
                    case JsmCommand.PREQSW:
                    {
                        AsmSegment                source           = evt.Segments.GetSegmentByOffset(i);
                        AsmValueSource            labelTargetEvent = AsmValueSource.Create(evt, i - 1);
                        AsmRelativeRequestBinding binding          = new AsmRelativeRequestBinding(source, i - source.Offset, operation.Argument, labelTargetEvent);
                        source.OutputBindings.Add(binding);
                        AsmSegment[] targets = binding.ResolveTargets();
                        if (targets != null)
                        {
                            foreach (AsmSegment target in targets)
                            {
                                target.InputBindings.Add(binding);
                            }
                        }
                        break;
                    }
                    }
                }
            }
        }
Esempio n. 3
0
 public AsmRelativeRequestBinding(AsmSegment source, int sourceOffset, int partyMember, AsmValueSource targetEventSource)
     : base(AsmBindingType.RelativeRequest, source, sourceOffset)
 {
     PartyMember       = partyMember;
     TargetEventSource = targetEventSource;
 }
Esempio n. 4
0
 AsmValueSource IAsmReadableCommandStack.Pop()
 {
     return(AsmValueSource.Create(_script, _offset++));
 }
Esempio n. 5
0
 void IAsmWriteableCommandStack.Push(AsmValueSource source)
 {
     source.Write(_script, _offset++);
 }
Esempio n. 6
0
        private void CreateInternalBindings(AsmSegments segments, List <int> jumpFrom, List <int> jumpTo)
        {
            for (int s = 0; s < segments.Count - 1; s++)
            {
                AsmSegment   source = segments[s];
                AsmSegment   target = segments[s + 1];
                JsmOperation last   = source[source.Length - 1];
                if (last.Command == JsmCommand.JPF)
                {
                    AsmConditionBinding binding = new AsmConditionBinding(source, target, AsmValueSource.Create(source, source.Length - 2), true);
                    source.OutputBindings.Add(binding);
                    target.InputBindings.Add(binding);
                }
                else if (last.Command != JsmCommand.JMP)
                {
                    AsmHardlinkBinding binding = new AsmHardlinkBinding(source, target);
                    source.OutputBindings.Add(binding);
                    target.InputBindings.Add(binding);
                }
            }

            for (int i = 0; i < jumpFrom.Count; i++)
            {
                int fromIndex = jumpFrom[i];
                int toIndex   = jumpTo[i];

                AsmSegment source = segments.GetSegmentByOffset(fromIndex);
                AsmSegment target = segments.GetSegmentByOffset(toIndex);

                JsmOperation last = source[source.Length - 1];
                if (last.Command == JsmCommand.JMP)
                {
                    AsmHardlinkBinding binding = new AsmHardlinkBinding(source, target);
                    source.OutputBindings.Add(binding);
                    target.InputBindings.Add(binding);
                }
                else if (last.Command == JsmCommand.JPF)
                {
                    AsmConditionBinding binding = new AsmConditionBinding(source, target, AsmValueSource.Create(source, source.Length - 2), false);
                    source.OutputBindings.Add(binding);
                    target.InputBindings.Add(binding);
                }
            }
        }