本文整理汇总了Golang中ql/interfaces.TypeCheckArgs.Symbols方法的典型用法代码示例。如果您正苦于以下问题:Golang TypeCheckArgs.Symbols方法的具体用法?Golang TypeCheckArgs.Symbols怎么用?Golang TypeCheckArgs.Symbols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ql/interfaces.TypeCheckArgs
的用法示例。
在下文中一共展示了TypeCheckArgs.Symbols方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TypeCheck
func (this VarDecl) TypeCheck(typeCheckArgs interfaces.TypeCheckArgs) {
// store type for identifier so when we find VarExpr with this VarID we know its real type (used during typechecking)
typeCheckArgs.Symbols().SetTypeForVarID(this.ValueType(), this.VariableIdentifier())
// we mark it as known to indicate that earlier references to this VarID are valid
typeCheckArgs.TypeChecker().MarkVarIDAsKnown(this.VariableIdentifier())
}
示例2: checkQuestionForRedeclarationWithDifferentTypes
// checkQuestionForRedeclarationWithDifferentTypes checks if the passed question has been declared before with a different type, and if so, adds an error to the typechecker
func checkQuestionForRedeclarationWithDifferentTypes(question interfaces.Question, typeCheckArgs interfaces.TypeCheckArgs) {
varDecl := question.VarDecl()
varID := varDecl.VariableIdentifier()
if typeCheckArgs.Symbols().IsTypeSetForVarID(varID) && typeCheckArgs.Symbols().TypeForVarID(varID) != varDecl.ValueType() {
typeCheckArgs.TypeChecker().AddEncounteredError(errors.NewQuestionRedeclaredWithDifferentTypesError(varDecl.ValueType(), typeCheckArgs.Symbols().TypeForVarID(varID)))
}
}
示例3: TypeCheck
func (this VarExpr) TypeCheck(typeCheckArgs interfaces.TypeCheckArgs) interfaces.ValueType {
typeCheckArgs.TypeChecker().AddDependencyForVarDecl(this.VarIdentifier(), typeCheckArgs.CurrentVarDeclVisited())
// Return the true type of the VarExpr; the type of the Expr referred to
if typeCheckArgs.Symbols().IsTypeSetForVarID(this.VarIdentifier()) {
return typeCheckArgs.Symbols().TypeForVarID(this.VarIdentifier()).(interfaces.ValueType)
}
// We don't already mark it as an error; because there is only one scope, the VarDecl may be simply declared later on
typeCheckArgs.TypeChecker().MarkVarIDAsUnknown(this.VarIdentifier())
// No type info in symbol table (reference to undefined question)
return NewUnknownType()
}