Ejemplo n.º 1
0
        public static StepBoundItem AutoItem(StepSyntax creatingSyntax)
        {
            var boundItem = new StepBoundItem(null, creatingSyntax);

            boundItem.IsAuto = true;
            return(boundItem);
        }
Ejemplo n.º 2
0
        public void BindRemainingValues()
        {
            foreach (var id in _unboundPointers.Keys)
            {
                if (!_itemMap.ContainsKey(id))
                {
                    var syntax = _unboundPointers[id].First().Item1;
                    throw new StepReadException($"Cannot bind undefined pointer {id}", syntax.Line, syntax.Column);
                }

                var item = _itemMap[id];
                foreach (var binder in _unboundPointers[id])
                {
                    var boundItem = new StepBoundItem(item, binder.Item1);
                    binder.Item2(boundItem);
                }
            }
        }
Ejemplo n.º 3
0
        public void BindValue(StepSyntax syntax, Action <StepBoundItem> bindAction)
        {
            if (syntax is StepSimpleItemSyntax)
            {
                var typedParameter = (StepSimpleItemSyntax)syntax;
                var item           = StepRepresentationItem.FromTypedParameter(this, typedParameter);
                var boundItem      = new StepBoundItem(item, syntax);
                bindAction(boundItem);
            }
            else if (syntax is StepEntityInstanceReferenceSyntax)
            {
                var itemInstance = (StepEntityInstanceReferenceSyntax)syntax;
                if (_itemMap.ContainsKey(itemInstance.Id))
                {
                    // pointer already defined, bind immediately
                    var boundItem = new StepBoundItem(_itemMap[itemInstance.Id], syntax);
                    bindAction(boundItem);
                }
                else
                {
                    // not already defined, save it for later
                    if (!_unboundPointers.ContainsKey(itemInstance.Id))
                    {
                        _unboundPointers.Add(itemInstance.Id, new List <Tuple <StepSyntax, Action <StepBoundItem> > >());
                    }

                    _unboundPointers[itemInstance.Id].Add(Tuple.Create(syntax, bindAction));
                }
            }
            else if (syntax is StepAutoSyntax)
            {
                bindAction(StepBoundItem.AutoItem(syntax));
            }
            else
            {
                throw new StepReadException("Unable to bind pointer, this should be unreachable", syntax.Line, syntax.Column);
            }
        }