def ExprSelect(id, operand, field): """ExprSelect(long id, object operand, str field) object ExprSelect creates a select Expr. """ return go.Ptr_expr_Expr( handle=_test.test_ExprSelect(id, operand.handle, field))
def PruneAst(expr, state): """PruneAst(object expr, object state) object PruneAst prunes the given AST based on the given EvalState and generates a new AST. Given AST is copied on write and a new AST is returned. Couple of typical use cases this interface would be: A) 1) Evaluate expr with some unknowns, 2) If result is unknown: a) PruneAst b) Goto 1 Functional call results which are known would be effectively cached across iterations. B) 1) Compile the expression (maybe via a service and maybe after checking a compiled expression does not exists in local cache) 2) Prepare the environment and the interpreter. Activation might be empty. 3) Eval the expression. This might return unknown or error or a concrete value. 4) PruneAst 4) Maybe cache the expression This is effectively constant folding the expression. How the environment is prepared in step 2 is flexible. For example, If the caller caches the compiled and constant folded expressions, but is not willing to constant fold(and thus cache results of) some external calls, then they can prepare the overloads accordingly. """ return go.Ptr_expr_Expr(handle=_interpreter.interpreter_PruneAst(expr.handle, state.handle))
def ExprComprehension(id, iterVar, iterRange, accuVar, accuInit, loopCondition, loopStep, resultExpr): """ExprComprehension(long id, str iterVar, object iterRange, str accuVar, object accuInit, object loopCondition, object loopStep, object resultExpr) object ExprComprehension returns a comprehension Expr. """ return go.Ptr_expr_Expr(handle=_test.test_ExprComprehension( id, iterVar, iterRange.handle, accuVar, accuInit.handle, loopCondition.handle, loopStep.handle, resultExpr.handle))
def __getitem__(self, key): if isinstance(key, slice): return [self[ii] for ii in range(*key.indices(len(self)))] elif isinstance(key, int): if key < 0: key += len(self) if key < 0 or key >= len(self): raise IndexError('slice index out of range') return go.Ptr_expr_Expr(handle=_interpreter.Slice_Ptr_expr_Expr_elem(self.handle, key)) else: raise TypeError('slice index invalid type')
def ExprIdent(id, name): """ExprIdent(long id, str name) object ExprIdent creates an ident (variable) Expr. """ return go.Ptr_expr_Expr(handle=_test.test_ExprIdent(id, name))
def Expr(self): return go.Ptr_expr_Expr( handle=_test.test_TestExpr_Expr_Get(self.handle))
def __getitem__(self, key): return go.Ptr_expr_Expr( handle=_test.Map_int64_Ptr_expr_Expr_elem(self.handle, key))
def Ident(self, name): """Ident(str name) object""" return go.Ptr_expr_Expr( handle=_parser.parser_ExprHelper_Ident(self.handle, name))
def PresenceTest(self, operand, field): """PresenceTest(object operand, str field) object""" return go.Ptr_expr_Expr(handle=_parser.parser_ExprHelper_PresenceTest( self.handle, operand.handle, field))
def LiteralUint(self, value): """LiteralUint(long value) object""" return go.Ptr_expr_Expr( handle=_parser.parser_ExprHelper_LiteralUint(self.handle, value))
def LiteralString(self, value): """LiteralString(str value) object""" return go.Ptr_expr_Expr( handle=_parser.parser_ExprHelper_LiteralString(self.handle, value))
def LiteralDouble(self, value): """LiteralDouble(float value) object""" return go.Ptr_expr_Expr( handle=_parser.parser_ExprHelper_LiteralDouble(self.handle, value))
def LiteralBytes(self, value): """LiteralBytes([]int value) object""" return go.Ptr_expr_Expr(handle=_parser.parser_ExprHelper_LiteralBytes( self.handle, value.handle))
def LiteralBool(self, value): """LiteralBool(bool value) object""" return go.Ptr_expr_Expr( handle=_parser.parser_ExprHelper_LiteralBool(self.handle, value))
def ExprLiteral(id, value): """ExprLiteral(long id, str value) object ExprLiteral creates a literal (constant) Expr. """ return go.Ptr_expr_Expr(handle=_test.test_ExprLiteral(id, value))
def Select(self, operand, field): """Select(object operand, str field) object""" return go.Ptr_expr_Expr(handle=_parser.parser_ExprHelper_Select( self.handle, operand.handle, field))
def Fold(self, iterVar, iterRange, accuVar, accuInit, condition, step, result): """Fold(str iterVar, object iterRange, str accuVar, object accuInit, object condition, object step, object result) object""" return go.Ptr_expr_Expr(handle=_parser.parser_ExprHelper_Fold( self.handle, iterVar, iterRange.handle, accuVar, accuInit.handle, condition.handle, step.handle, result.handle))