<s> import math <EOL> import call_definitions <EOL> from appvalidator . constants import JS_DEBUG <EOL> from call_definitions import python_wrap <EOL> from entity_values import entity <EOL> from jstypes import JSGlobal , JSLiteral <EOL> def resolve_entity ( traverser , * args ) : <EOL> element = GLOBAL_ENTITIES [ args [ <NUM_LIT:0> ] ] <EOL> for layer in args [ <NUM_LIT:1> : ] : <EOL> value = element [ "<STR_LIT:value>" ] <EOL> while callable ( value ) : <EOL> value = value ( t = t ) <EOL> element = value [ layer ] <EOL> return element <EOL> def get_global ( * args ) : <EOL> return lambda trav : resolve_entity ( trav , * args ) <EOL> global_identity = { "<STR_LIT:value>" : lambda * args : GLOBAL_ENTITIES } <EOL> READONLY = { "<STR_LIT>" : True } <EOL> def feature ( constant , fallback = None ) : <EOL> def wrap ( t ) : <EOL> t . log_feature ( constant ) <EOL> t . _debug ( "<STR_LIT>" % constant ) <EOL> if fallback : <EOL> t . _debug ( "<STR_LIT>" % repr ( fallback ) ) <EOL> return lambda * a : fallback if fallback else { } <EOL> return { '<STR_LIT:value>' : wrap , <EOL> '<STR_LIT>' : lambda ** kw : kw [ '<STR_LIT>' ] . log_feature ( constant ) } <EOL> MOZAPPS = { <EOL> u'<STR_LIT>' : feature ( '<STR_LIT>' ) , <EOL> } <EOL> NAVIGATOR = { <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" , MOZAPPS ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" , MOZAPPS ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT:time>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : entity ( "<STR_LIT>" ) , <EOL> } <EOL> GLOBAL_ENTITIES = { <EOL> u"<STR_LIT>" : global_identity , <EOL> u"<STR_LIT:null>" : { "<STR_LIT>" : None } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : global_identity , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> } , <EOL> } , <EOL> u"<STR_LIT>" : entity ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : entity ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : entity ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : entity ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } , <EOL> "<STR_LIT>" : call_definitions . string_global , <EOL> "<STR_LIT>" : call_definitions . string_global , <EOL> "<STR_LIT>" : "<STR_LIT:string>" } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } , <EOL> "<STR_LIT>" : call_definitions . array_global , <EOL> "<STR_LIT>" : call_definitions . array_global } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : float ( '<STR_LIT>' ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : float ( '<STR_LIT>' ) } , <EOL> u"<STR_LIT>" : get_global ( "<STR_LIT>" ) } , <EOL> "<STR_LIT>" : call_definitions . number_global , <EOL> "<STR_LIT>" : call_definitions . number_global , <EOL> "<STR_LIT>" : "<STR_LIT>" } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } , <EOL> "<STR_LIT>" : call_definitions . boolean_global , <EOL> "<STR_LIT>" : call_definitions . boolean_global , <EOL> "<STR_LIT>" : "<STR_LIT>" } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT:value>" : get_global ( "<STR_LIT>" ) } } } , <EOL> u"<STR_LIT>" : <EOL> { "<STR_LIT:value>" : <EOL> { u"<STR_LIT>" : { "<STR_LIT>" : math . pi } , <EOL> u"<STR_LIT:E>" : { "<STR_LIT>" : math . e } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . log ( <NUM_LIT:2> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . log ( <NUM_LIT:10> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . log ( math . e , <NUM_LIT:2> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . log10 ( math . e ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . sqrt ( <NUM_LIT:2> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : math . sqrt ( <NUM_LIT:1> / <NUM_LIT:2> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( abs , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . acos , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . asin , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . atan , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . atan2 , [ ( "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:1> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . ceil , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . cos , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . exp , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . floor , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : call_definitions . math_log } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( max , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] , nargs = True ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( min , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] , nargs = True ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . pow , [ ( "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : lambda ** kw : JSLiteral ( <NUM_LIT:0.5> ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : call_definitions . math_round } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . sin , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . sqrt , [ ( "<STR_LIT>" , <NUM_LIT:1> ) ] ) } , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : python_wrap ( math . tan , [ ( "<STR_LIT>" , <NUM_LIT:0> ) ] ) } , <EOL> } , <EOL> } , <EOL> u"<STR_LIT>" : entity ( '<STR_LIT>' ) , <EOL> u"<STR_LIT>" : get_global ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : READONLY , <EOL> u"<STR_LIT>" : { "<STR_LIT>" : True , "<STR_LIT>" : True , "<STR_LIT>" : None } , <EOL> u"<STR_LIT>" : global_identity , <EOL> u"<STR_LIT>" : { "<STR_LIT:value>" : NAVIGATOR } , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> <STR_LIT> : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> u"<STR_LIT>" : feature ( "<STR_LIT>" ) , <EOL> } <EOL> def enable_debug ( ) : <EOL> def assert_ ( wrapper , arguments , traverser ) : <EOL> traverser . asserts = True <EOL> for arg in arguments : <EOL> if not arg . get_literal_value ( traverser ) : <EOL> traverser . err . error ( <EOL> err_id = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> error = "<STR_LIT>" % arg , <EOL> description = "<STR_LIT>" ) <EOL> GLOBAL_ENTITIES [ u"<STR_LIT>" ] = { "<STR_LIT>" : assert_ } <EOL> def callable_ ( wrapper , arguments , traverser ) : <EOL> traverser . asserts = True <EOL> for arg in arguments : <EOL> if not arg . callable : <EOL> traverser . err . error ( <EOL> err_id = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> error = "<STR_LIT>" % arg , <EOL> description = "<STR_LIT>" ) <EOL> GLOBAL_ENTITIES [ u"<STR_LIT>" ] = { "<STR_LIT>" : assert_ } </s>
