本文整理汇总了Python中ufora.native.FORA.evaluateRootLevelCreateObjectExpression方法的典型用法代码示例。如果您正苦于以下问题:Python FORA.evaluateRootLevelCreateObjectExpression方法的具体用法?Python FORA.evaluateRootLevelCreateObjectExpression怎么用?Python FORA.evaluateRootLevelCreateObjectExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ufora.native.FORA
的用法示例。
在下文中一共展示了FORA.evaluateRootLevelCreateObjectExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: specializeFreeVariableMemberAccessChainsAndEvaluate
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import evaluateRootLevelCreateObjectExpression [as 别名]
def specializeFreeVariableMemberAccessChainsAndEvaluate(self,
foraExpression,
renamedVariableMapping):
foraExpression, renamedVariableMapping = \
self.specializeFreeVariableMemberAccessChains(
foraExpression,
renamedVariableMapping
)
allAreIVC = True
for _, v in renamedVariableMapping.iteritems():
if not isinstance(v, ForaNative.ImplValContainer):
allAreIVC = False
if allAreIVC:
missingVariableDefinitions = [
x for x in foraExpression.freeVariables if x not in renamedVariableMapping
]
if missingVariableDefinitions:
raise pyfora.PythonToForaConversionError(
("An internal error occurred: we didn't provide a " +
"definition for the following variables: %s" % missingVariableDefinitions +
". Most likely, there is a mismatch between our analysis of the "
"python code and the generated FORA code underneath. Please file a bug report."
))
#we need to determine whether we should bind the free variables in this expression as constants
#inline in the code, or as class members. Binding them as constants speeds up the compiler,
#but if we have the same function bound repeatedly with many constants, we'll end up
#producing far too much code. This algorithm binds as constants the _First_ time we bind
#a given expression with given arguments, and as members any future set of times. This
#should cause it to bind modules and classes that don't have any data flowing through them
#as constants, and closures and functions we're calling repeatedly using class members.
shouldMapArgsAsConstants = True
boundValues = tuple(renamedVariableMapping[k].hash for k in sorted(renamedVariableMapping))
if foraExpression.hash() not in self.boundExpressions:
self.boundExpressions[foraExpression.hash()] = boundValues
else:
bound = self.boundExpressions[foraExpression.hash()]
if boundValues != bound:
shouldMapArgsAsConstants = False
return ForaNative.evaluateRootLevelCreateObjectExpression(
foraExpression,
renamedVariableMapping,
shouldMapArgsAsConstants
)
else:
#function that evaluates the CreateObject. Args are the free variables, in lexical order
expressionAsIVC = foraExpression.toFunctionImplval(False)
args = []
for f in foraExpression.freeVariables:
args.append(renamedVariableMapping[f])
res = ComputedValue.ComputedValue(args=(expressionAsIVC, Symbol_Call) + tuple(args))
return res
示例2: stacktrace
# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import evaluateRootLevelCreateObjectExpression [as 别名]
self.completable_.put(node)
return
callAndReturnExpr = FORANative.parseStringToExpression(
"""object {
...(f, *args) {
try { (f`(*args), (f, *args), 'callAndReturnExpr') }
catch from stacktrace (e) { throw from stacktrace (e, (f, *args)) }
}
}""",
FORANative.CodeDefinitionPoint(),
"cdp"
)
callAndReturn = FORANative.evaluateRootLevelCreateObjectExpression(callAndReturnExpr, {}, True)
def areAllArgumentsConst(*args):
"""Returns True if all ImplValContainer arguments in the specified list are const."""
for arg in args:
if not arg.isCST():
return False
return True
class LocalEvaluator(EvaluatorBase.EvaluatorBase):
def __init__(self,
offlineCacheFunction,
newMemLimit,
remoteEvaluator=None,
newLoadRatio=.5,
maxPageSizeInBytes=None,