public override void ResolveReferences(Story context) { if (!context.ResolveVariableWithName(varName, fromNode: this).found) { Error("variable for " + incrementDecrementWord + " could not be found: '" + varName + "' after searching: " + this.descriptionOfScope); } }
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); } } } }
public override void ResolveReferences (Story context) { base.ResolveReferences (context); VariableAssignment varDecl = null; if (this.isNewTemporaryDeclaration && story.variableDeclarations.TryGetValue(variableName, out varDecl) ) { if (varDecl.isGlobalDeclaration) { Error ("global variable '" + variableName + "' already exists with the same name (declared on " + varDecl.debugMetadata + ")"); return; } } if (this.isGlobalDeclaration) { var variableReference = expression as VariableReference; if (variableReference && !variableReference.isConstantReference) { Error ("global variable assignments cannot refer to other variables, only literal values and constants"); } } if (IsReservedKeyword (variableName)) { Error ("cannot use '" + variableName + "' as a variable since it's a reserved ink keyword"); return; } 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); } } } }
public override void ResolveReferences(Story context) { base.ResolveReferences(context); if (!context.ResolveVariableWithName(varName, fromNode: this).found) { Error("variable for " + incrementDecrementWord + " could not be found: '" + varName + "' after searching: " + this.descriptionOfScope); } if (!(parent is Weave) && !(parent is FlowBase)) { Error("Can't use " + incrementDecrementWord + " as sub-expression"); } }
public override void ResolveReferences(Story context) { base.ResolveReferences(context); // Work is already done if it's a constant reference if (isConstantReference) { return; } // Is it a read count? var parsedPath = new Path(path); Parsed.Object targetForCount = parsedPath.ResolveFromContext(this); if (targetForCount) { targetForCount.containerForCounting.visitsShouldBeCounted = true; _runtimeVarRef.pathForCount = targetForCount.runtimePath; _runtimeVarRef.name = null; // Check for very specific writer error: getting read count and // printing it as content rather than as a piece of logic // e.g. Writing {myFunc} instead of {myFunc()} var targetFlow = targetForCount as FlowBase; if (targetFlow && targetFlow.isFunction) { // Is parent context content rather than logic? if (parent is Weave || parent is ContentList || parent is FlowBase) { Warning("'" + targetFlow.name + "' being used as read count rather than being called as function. Perhaps you intended to write " + targetFlow.name + "()"); } } return; } // Definitely a read count, but wasn't found? else if (path.Count > 1) { Error("Could not find target for read count: " + parsedPath); return; } if (!context.ResolveVariableWithName(this.name, fromNode: this).found) { Error("Unresolved variable: " + this.ToString(), this); } }
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) { // Don't allow reserved words for argument names if (VariableAssignment.IsReservedKeyword(arg.name)) { Error("Argument '" + arg.name + "' is a reserved word, please choose another name"); continue; } // Does argument conflict with a knot/stitch/label? var pathOfTheoreticalTarget = new Path(arg.name); Parsed.Object target = pathOfTheoreticalTarget.ResolveFromContext(this); if (target) { Error("Argument '" + arg.name + "' conflicts with a " + target.GetType().Name + " on " + target.debugMetadata + ", "); continue; } // Does argument conflict with another variable name? if (context.ResolveVariableWithName(arg.name, fromNode: this.parent).found) { Error("Argument '" + arg.name + "' conflicts with existing variable definition at higher scope."); continue; } } } }
public override void ResolveReferences(Story context) { base.ResolveReferences(context); VariableAssignment varDecl = null; if (this.isNewTemporaryDeclaration && story.variableDeclarations.TryGetValue(variableName, out varDecl)) { if (varDecl.isGlobalDeclaration) { Error("global variable '" + variableName + "' already exists with the same name (declared on " + varDecl.debugMetadata + ")"); return; } } 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 (IsReservedKeyword(variableName)) { Error("cannot use '" + variableName + "' as a variable since it's a reserved ink keyword"); return; } 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); } } } }
public override void ResolveReferences(Story context) { base.ResolveReferences(context); var varResolveResult = context.ResolveVariableWithName(varIdentifier?.name, fromNode: this); if (!varResolveResult.found) { Error("variable for " + incrementDecrementWord + " could not be found: '" + varIdentifier + "' after searching: " + this.descriptionOfScope); } _runtimeAssignment.isGlobal = varResolveResult.isGlobal; if (!(parent is Weave) && !(parent is FlowBase) && !(parent is ContentList)) { Error("Can't use " + incrementDecrementWord + " as sub-expression"); } }
public override void ResolveReferences (Story context) { base.ResolveReferences (context); // Work is already done if it's a constant reference if (isConstantReference) { return; } // Is it a read count? var parsedPath = new Path (path); Parsed.Object targetForCount = parsedPath.ResolveFromContext (this); if (targetForCount) { targetForCount.containerForCounting.visitsShouldBeCounted = true; _runtimeVarRef.pathForCount = targetForCount.runtimePath; _runtimeVarRef.name = null; // Check for very specific writer error: getting read count and // printing it as content rather than as a piece of logic // e.g. Writing {myFunc} instead of {myFunc()} var targetFlow = targetForCount as FlowBase; if (targetFlow && targetFlow.isFunction) { // Is parent context content rather than logic? if ( parent is Weave || parent is ContentList || parent is FlowBase) { Warning ("'" + targetFlow.name + "' being used as read count rather than being called as function. Perhaps you intended to write " + targetFlow.name + "()"); } } return; } // Definitely a read count, but wasn't found? else if (path.Count > 1) { Error ("Could not find target for read count: " + parsedPath); return; } if (!context.ResolveVariableWithName (this.name, fromNode: this).found) { Error("Unresolved variable: "+this.ToString(), this); } }
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; } } }
public override void ResolveReferences (Story context) { if (!context.ResolveVariableWithName (varName, fromNode:this).found) { Error ("variable for "+incrementDecrementWord+" could not be found: '"+varName+"' after searching: "+this.descriptionOfScope); } }
public override void ResolveReferences(Story context) { base.ResolveReferences(context); // Work is already done if it's a constant or list item reference if (isConstantReference || isListItemReference) { return; } // Is it a read count? var parsedPath = new Path(pathIdentifiers); Parsed.Object targetForCount = parsedPath.ResolveFromContext(this); if (targetForCount) { targetForCount.containerForCounting.visitsShouldBeCounted = true; // If this is an argument to a function that wants a variable to be // passed by reference, then the Parsed.Divert will have generated a // Runtime.VariablePointerValue instead of allowing this object // to generate its RuntimeVariableReference. This only happens under // error condition since we shouldn't be passing a read count by // reference, but we don't want it to crash! if (_runtimeVarRef == null) { return; } _runtimeVarRef.pathForCount = targetForCount.runtimePath; _runtimeVarRef.name = null; // Check for very specific writer error: getting read count and // printing it as content rather than as a piece of logic // e.g. Writing {myFunc} instead of {myFunc()} var targetFlow = targetForCount as FlowBase; if (targetFlow && targetFlow.isFunction) { // Is parent context content rather than logic? if (parent is Weave || parent is ContentList || parent is FlowBase) { Warning("'" + targetFlow.identifier + "' being used as read count rather than being called as function. Perhaps you intended to write " + targetFlow.name + "()"); } } return; } // Couldn't find this multi-part path at all, whether as a divert // target or as a list item reference. if (path.Count > 1) { var errorMsg = "Could not find target for read count: " + parsedPath; if (path.Count <= 2) { errorMsg += ", or couldn't find list item with the name " + string.Join(",", path.ToArray()); } Error(errorMsg); return; } if (!context.ResolveVariableWithName(this.name, fromNode: this).found) { Error("Unresolved variable: " + this.ToString(), this); } }
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) { // Don't allow reserved words for argument names if (VariableAssignment.IsReservedKeyword (arg.name)) { Error ("Argument '" + arg.name + "' is a reserved word, please choose another name"); continue; } // Does argument conflict with a knot/stitch/label? var pathOfTheoreticalTarget = new Path (arg.name); Parsed.Object target = pathOfTheoreticalTarget.ResolveFromContext (this); if (target) { Error ("Argument '" + arg.name + "' conflicts with a " + target.GetType().Name + " on " + target.debugMetadata + ", "); continue; } // Does argument conflict with another variable name? if (context.ResolveVariableWithName (arg.name, fromNode: this.parent).found) { Error("Argument '"+ arg.name + "' conflicts with existing variable definition at higher scope."); continue; } } } }