当前位置: 首页>>代码示例>>Golang>>正文


Golang interfaces.TypeCheckArgs类代码示例

本文整理汇总了Golang中ql/interfaces.TypeCheckArgs的典型用法代码示例。如果您正苦于以下问题:Golang TypeCheckArgs类的具体用法?Golang TypeCheckArgs怎么用?Golang TypeCheckArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TypeCheckArgs类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: checkForNonBoolCondition

// checkForNonBoolCondition checks if the condition is of a boolean type, and if not, adds an error to the typechecker
func checkForNonBoolCondition(condition interfaces.Expr, typeCheckArgs interfaces.TypeCheckArgs) {
	typeOfCondition := condition.TypeCheck(typeCheckArgs)

	if typeOfCondition != expr.NewBoolType() && typeOfCondition != expr.NewUnknownType() {
		typeCheckArgs.TypeChecker().AddEncounteredError(errors.NewNonBooleanConditionError(condition, typeOfCondition))
	}
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:8,代码来源:typecheckstmt.go

示例2: 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())
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:7,代码来源:typecheckvari.go

示例3: TypeCheck

func (this If) TypeCheck(typeCheckArgs interfaces.TypeCheckArgs) {
	checkForNonBoolCondition(this.Condition(), typeCheckArgs)

	this.Condition().TypeCheck(typeCheckArgs)
	typeCheckArgs = typeCheckArgs.AddConditionDependentOn(this.Condition())

	this.Body().TypeCheck(typeCheckArgs)
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:8,代码来源:typecheckstmt.go

示例4: checkIfQuestionTypeMatchesComputationType

// checkIfQuestionTypeMatchesComputationType checks if the declared computed question type and its actual type match, and if not, adds an error to the typechecker
func (this ComputedQuestion) checkIfQuestionTypeMatchesComputationType(typeCheckArgs interfaces.TypeCheckArgs) {
	actualType := this.Computation().TypeCheck(typeCheckArgs)
	expectedType := this.VarDeclValueType()

	// check if question declaration type matches the type of the computation
	if actualType != expr.NewUnknownType() && actualType != expectedType {
		typeCheckArgs.TypeChecker().AddEncounteredError(errors.NewDeclaratedTypeAndActualTypeDeviateError(expectedType, actualType))
	}
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:10,代码来源:typecheckstmt.go

示例5: checkForEqualTypes

// checkForEqualTypes checks if the operands in a BinaryOperator have the same type, and if the types are unequal adds an error to the typechecker
func (binaryExpr BinaryOperator) checkForEqualTypes(typeCheckArgs interfaces.TypeCheckArgs) {
	lhsType := binaryExpr.LHS().TypeCheck(typeCheckArgs)
	rhsType := binaryExpr.RHS().TypeCheck(typeCheckArgs)

	if lhsType == NewUnknownType() || rhsType == NewUnknownType() {
		return
	}

	if lhsType != rhsType {
		typeCheckArgs.TypeChecker().AddEncounteredError(errors.NewOperandsOfDifferentTypesError(binaryExpr, lhsType, rhsType))
	}
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:13,代码来源:typecheckexpr.go

示例6: checkIfOperandHasExpectedType

// checkIfOperandHasExpectedType checks that an operand's actual type matches it expected type, and if not adds an error to the typechecker
func checkIfOperandHasExpectedType(expr interfaces.Expr, expectedTypes []interfaces.ValueType, typeCheckArgs interfaces.TypeCheckArgs) interfaces.ValueType {
	actualType := expr.TypeCheck(typeCheckArgs)

	if actualType == NewUnknownType() {
		return NewUnknownType()
	}

	if !typeIsInExpectedTypes(actualType, expectedTypes) {
		typeCheckArgs.TypeChecker().AddEncounteredError(errors.NewOperandWithUnexpectedTypeError(expr, expectedTypes, actualType))
	}

	return actualType
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:14,代码来源:typecheckexpr.go

示例7: 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()
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:14,代码来源:typecheckexpr.go

示例8: 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)))
	}
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:9,代码来源:typecheckstmt.go

示例9: collectVarIDsInExpressions

func collectVarIDsInExpressions(typeCheckArgs interfaces.TypeCheckArgs) {
	// for these condition expressions, running TypeCheck will collect VarIDs in them and add them as dependencies
	for _, conditionDependentOn := range typeCheckArgs.ConditionsDependentOn() {
		conditionDependentOn.TypeCheck(typeCheckArgs)
	}
}
开发者ID:software-engineering-amsterdam,项目名称:multi-ql,代码行数:6,代码来源:typecheckstmt.go


注:本文中的ql/interfaces.TypeCheckArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。