コード例 #1
0
// checkForUndefinedReferences seeks to confirm that all identifiers encountered have been marked as known (being declared)
func (this Form) checkForUndefinedReferences(typeChecker interfaces.TypeChecker) {
	for identifier, identifierKnown := range typeChecker.KnownIdentifiers() {
		if !identifierKnown {
			typeChecker.AddEncounteredError(errors.NewUndefinedQuestionReferenceError(identifier))
		}
	}
}
コード例 #2
0
// checkQuestionForDuplicateLabels checks if there are multiple questions with the same label, and if so, adds an warning to the typechecker
func checkQuestionForDuplicateLabels(question interfaces.Question, typeChecker interfaces.TypeChecker) {
	labelKnown := typeChecker.IsLabelUsed(question.Label())

	if labelKnown {
		typeChecker.AddEncounteredWarning(errors.NewDuplicateLabelWarning(question, typeChecker.VarIDForLabel(question.Label())))
		return
	}

	typeChecker.MarkLabelAsUsed(question.Label(), question.VarDecl())
}
コード例 #3
0
// checkForCyclicDependencies checks if the this question depends on itself, and if so, adds an error to the typechecker
func checkForCyclicDependencies(question interfaces.Question, typeChecker interfaces.TypeChecker) {
	// if we find our own VarID as a dependency at least once, the dependencyChain is cyclic
	if typeChecker.DependencyListForVarDeclContainsReferenceToSelf(question.VarDecl()) {
		typeChecker.AddEncounteredError(errors.NewCyclicDependencyError(question.VarDecl()))
	}
}