예제 #1
0
        public override void ResolveReferences(Story context)
        {
            base.ResolveReferences(context);

            // List definitions are checked for conflicts separately
            if (this.isDeclaration && listDefinition == null)
            {
                context.CheckForNamingCollisions(this, variableName, this.isGlobalDeclaration ? Story.SymbolType.Var : Story.SymbolType.Temp);
            }

            if (this.isGlobalDeclaration)
            {
                var variableReference = expression as VariableReference;
                if (variableReference && !variableReference.isConstantReference && !variableReference.isListItemReference)
                {
                    Error("global variable assignments cannot refer to other variables, only literal values, constants and list items");
                }
            }

            if (!this.isNewTemporaryDeclaration)
            {
                if (!context.ResolveVariableWithName(this.variableName, fromNode: this).found)
                {
                    if (story.constants.ContainsKey(variableName))
                    {
                        Error("Can't re-assign to a constant (do you need to use VAR when declaring '" + this.variableName + "'?)", this);
                    }
                    else
                    {
                        Error("Variable could not be found to assign to: '" + this.variableName + "'", this);
                    }
                }
            }
        }
예제 #2
0
        public override void ResolveReferences(Story context)
        {
            if (_startingSubFlowDivert)
            {
                _startingSubFlowDivert.targetPath = _startingSubFlowRuntime.path;
            }

            base.ResolveReferences(context);

            // Check validity of parameter names
            if (arguments != null)
            {
                foreach (var arg in arguments)
                {
                    context.CheckForNamingCollisions(this, arg.identifier, Story.SymbolType.Arg, "argument");
                }

                // Separately, check for duplicate arugment names, since they aren't Parsed.Objects,
                // so have to be checked independently.
                for (int i = 0; i < arguments.Count; i++)
                {
                    for (int j = i + 1; j < arguments.Count; j++)
                    {
                        if (arguments [i].identifier?.name == arguments [j].identifier?.name)
                        {
                            Error("Multiple arguments with the same name: '" + arguments [i].identifier + "'");
                        }
                    }
                }
            }

            // Check naming collisions for knots and stitches
            if (flowLevel != FlowLevel.Story)
            {
                // Weave points aren't FlowBases, so this will only be knot or stitch
                var symbolType = flowLevel == FlowLevel.Knot ? Story.SymbolType.Knot : Story.SymbolType.SubFlowAndWeave;
                context.CheckForNamingCollisions(this, identifier, symbolType);
            }
        }
예제 #3
0
        public override void ResolveReferences(Story context)
        {
            base.ResolveReferences(context);

            // List definitions are checked for conflicts separately
            if (this.isDeclaration && listDefinition == null)
            {
                context.CheckForNamingCollisions(this, variableName, this.isGlobalDeclaration ? Story.SymbolType.Var : Story.SymbolType.Temp);
            }

            // Initial VAR x = [intialValue] declaration, not re-assignment
            if (this.isGlobalDeclaration)
            {
                var variableReference = expression as VariableReference;
                if (variableReference && !variableReference.isConstantReference && !variableReference.isListItemReference)
                {
                    Error("global variable assignments cannot refer to other variables, only literal values, constants and list items");
                }
            }

            if (!this.isNewTemporaryDeclaration)
            {
                var resolvedVarAssignment = context.ResolveVariableWithName(this.variableName, fromNode: this);
                if (!resolvedVarAssignment.found)
                {
                    if (story.constants.ContainsKey(variableName))
                    {
                        Error("Can't re-assign to a constant (do you need to use VAR when declaring '" + this.variableName + "'?)", this);
                    }
                    else
                    {
                        Error("Variable could not be found to assign to: '" + this.variableName + "'", this);
                    }
                }

                // A runtime assignment may not have been generated if it's the initial global declaration,
                // since these are hoisted out and handled specially in Story.ExportRuntime.
                if (_runtimeAssignment != null)
                {
                    _runtimeAssignment.isGlobal = resolvedVarAssignment.isGlobal;
                }
            }
        }
예제 #4
0
        public override void ResolveReferences(Story context)
        {
            // Weave style choice - target own content container
            if (_innerContentContainer)
            {
                _runtimeChoice.pathOnChoice = _innerContentContainer.path;

                if (onceOnly)
                {
                    _innerContentContainer.visitsShouldBeCounted = true;
                }
            }

            if (_returnToR1)
            {
                _returnToR1.targetPath = _r1Label.path;
            }

            if (_returnToR2)
            {
                _returnToR2.targetPath = _r2Label.path;
            }

            if (_divertToStartContentOuter)
            {
                _divertToStartContentOuter.targetPath = _startContentRuntimeContainer.path;
            }

            if (_divertToStartContentInner)
            {
                _divertToStartContentInner.targetPath = _startContentRuntimeContainer.path;
            }

            base.ResolveReferences(context);

            if (name != null && name.Length > 0)
            {
                context.CheckForNamingCollisions(this, name, Story.SymbolType.SubFlowAndWeave);
            }
        }
예제 #5
0
        public override void ResolveReferences(Story context)
        {
            if (_finalLooseEndTarget)
            {
                var flowEndPath = _finalLooseEndTarget.path;
                foreach (var finalLooseEndDivert in _finalLooseEnds)
                {
                    finalLooseEndDivert.targetPath = flowEndPath;
                }
            }

            if (_startingSubFlowDivert)
            {
                _startingSubFlowDivert.targetPath = _startingSubFlowRuntime.path;
            }

            base.ResolveReferences(context);

            // Check validity of parameter names
            if (arguments != null)
            {
                foreach (var arg in arguments)
                {
                    context.CheckForNamingCollisions(this, arg.name, Story.SymbolType.Arg, "argument");
                }

                // Separately, check for duplicate arugment names, since they aren't Parsed.Objects,
                // so have to be checked independently.
                for (int i = 0; i < arguments.Count; i++)
                {
                    for (int j = i + 1; j < arguments.Count; j++)
                    {
                        if (arguments [i].name == arguments [j].name)
                        {
                            Error("Multiple arguments with the same name: '" + arguments [i].name + "'");
                        }
                    }
                }
            }
        }
예제 #6
0
        //public override Runtime.Object GenerateRuntimeObject ()
        //{
        //    var initialValues = new Runtime.InkList ();
        //    foreach (var itemDef in itemDefinitions) {
        //        if (itemDef.inInitialList) {
        //            var item = new Runtime.InkListItem (this.name, itemDef.name);
        //            initialValues [item] = itemDef.seriesValue;
        //        }
        //    }

        //    // Set origin name, so
        //    initialValues.SetInitialOriginName (name);

        //    return new Runtime.ListValue (initialValues);
        //}

        public override void ResolveReferences(Story context)
        {
            base.ResolveReferences(context);

            context.CheckForNamingCollisions(this, name, Story.SymbolType.List);
        }