def main(): if len(sys.argv) < 2: print(''' Usage: python -m F1 <grammar.json> ''') sys.exit(1) gfile = sys.argv[1] with open(gfile) as gf: fc = gf.read() my_grammar = json.loads(fc) c_grammar = F1.CTrans(my_grammar).translate() vm_ops, main_src, fuzz_src = F1.CFWriteCTFuzzer(c_grammar).fuzz_src() with open('vm_ops.s', 'w+') as f: print(vm_ops, file=f) with open('fuzz.s', 'w+') as f: print(fuzz_src, file=f) with open('main.c', 'w+') as f: print(main_src, file=f) print('''\ Next step: $ cc -g -Ofast -o fuzzer main.c fuzz.s $ rm -f io.x $ ./fuzzer 0 1000 1000 $ cat io.x ''')
def main(): if len(sys.argv) < 2: print(''' Usage: python -m F1 <grammar.json> ''') sys.exit(1) gfile = sys.argv[1] with open(gfile) as gf: fc = gf.read() my_grammar = json.loads(fc) c_grammar = F1.CTrans(my_grammar).translate() vm_ops, main_src, fuzz_src = F1.CFWriteCTFuzzer(c_grammar).fuzz_src() with open('vm_ops.s', 'w+') as f: print(vm_ops, file=f) with open('fuzz.S', 'w+') as f: print(fuzz_src, file=f) with open('main.c', 'w+') as f: print(main_src, file=f) uname = os.uname() print('\nNext step:') if uname.sysname == "Darwin": print('$ cc -g -Ofast -o fuzzer main.c fuzz.S') elif uname.sysname == "Linux": print('$ clang -g -Ofast -mcmodel=medium -o fuzzer main.c fuzz.S') print('''$ rm -f io.x $ ./fuzzer 0 1000 1000 $ cat io.x ''')
def room10(): print '你来到了二楼堂屋,这里有三扇门<前、左、右>,请选择:' print '''1、开启前门 2、开启左门 3、开启右门 4、回去厨房 5、结束浏览''' choose = int(raw_input('请选择1-4:')) if choose == 1: room11() elif choose == 2: room8() elif choose == 3: room9() elif choose == 4: F1.room5() elif choose == 5: status.over() else: status.dead()
return([111,222,333]); # make a pair of forked pipes c = RMI.Client.ForkedPipes() ok(c, "got forked pipe client"); r = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['2+3']); is_ok(r,5,'result of remote eval of 2+3 is 5') sum1 = c.send_request_and_receive_response('call_function', None, '__main__.addo', [7,8]) is_ok(sum1,15,'result of remote function call __main__.addo(7,8) works') sum2 = c.send_request_and_receive_response('call_function', None, 'F1.add', [4,5]); ok(sum2, 'remote function call with primitives works') val3 = F1.x1() is_ok(val3,11,'result of local functin call to plain function works') local1 = F1.C1(); ok_show(local1, 'local constructor works') if local1: ok_show(local1.m1, 'local object property access works') remote1 = c.send_request_and_receive_response('call_function', None, 'F1.echo', [local1]); is_ok(remote1, local1, 'remote function call with object echo works') note("test returning an array") remote2 = c.send_request_and_receive_response('call_function', None, '__main__.getarray', []); ok_show(remote2, 'got a result, hopefully an array'); value = remote2[0] ok_show(value, "got a value from the proxy array");
import F1 s=0 print("Function list:") print("1: F(x,y)=F(x-y,y)+1, if y ≤ x") print("2: F(n,r)=F(n-1,r)+F(n-1,r-1)") print("3: F(n)=F(n/2)+1 if n>1") print("4: F(M,N)=1 if M=0, or M ≥N ≥1, and F(M,N)=F(M-1,N)+F(M-1,N-1), otherwise.") print("5: B(m,x)=m!/(x!(m-x)!) where m>x,B(0,0)=B(m,0)=1 and B(m,x)=B(m,x-1)*[(m-x+1)/x]") i=int(input("Enter your choice: ")) if(i==1): a=int(input("Enter the value of x: ")) b=int(input("Enter the value of y: ")) s=s+F1.f1(a,b) print("Result: ",s) elif(i==2): n=int(input("Enter the value of n: ")) r=int(input("Enter the value of r: ")) s=s+F1.f2(n,r) print("Result: ",s) elif(i==3): n=int(input("Enter the value of n: ")) s=s+F1.f3(n) print("Result: ",s) elif(i==4): m=int(input("Enter the value of m: ")) n=int(input("Enter the value of n: ")) s=s+F1.f4(m,n) print("Result: ",s) elif(i==5): m=int(input("Enter the value of m: ")) x=int(input("Enter the value of x: "))
def t5(self): c = self.c r = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['2+3']); self.is_ok(r,5,'result of remote eval of 2+3 is 5') sum1 = c.send_request_and_receive_response('call_function', None, '__main__.addo', [7,8]) is_ok(sum1,15,'result of remote function call __main__.addo(7,8) works') sum2 = c.send_request_and_receive_response('call_function', None, 'F1.add', [4,5]); ok(sum2, 'remote function call with primitives works') val3 = F1.x1() is_ok(val3,11,'result of local functin call to plain function works') local1 = F1.C1(); ok_show(local1, 'local constructor works') if local1: ok_show(local1.m1, 'local object property access works') remote1 = c.send_request_and_receive_response('call_function', None, 'F1.echo', [local1]); is_ok(remote1, local1, 'remote function call with object echo works') note("test returning an array") remote2 = c.send_request_and_receive_response('call_function', None, '__main__.getarray', []); ok_show(remote2, 'got a result, hopefully an array'); value = remote2[0] ok_show(value, "got a value from the proxy array"); ok_show(str(remote2[0]), "got value 1"); ok_show(str(remote2[1]), "got value 2"); ok_show(str(remote2[2]), "got value 3"); note("test returning a usable lambda expression with zero params"); remote4 = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['lambda: 555']); ok(remote4 != None, 'remote lambda construction works') val2 = remote4() is_ok(val2,555,"remote lambda works with zero params") note("test returning a usable lambda expression with two params"); remote3 = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['lambda a,b: a+b']); ok(remote3 != None, 'remote lambda construction works with params') val3 = remote3(6,2) is_ok(val3,8,"remote lambda works with params") note("testing returning a remote object from a function") remote5 = c.send_request_and_receive_response('call_function', None, 'F1.C1',[]); val2 = remote5.m1() is_ok(val2,"456","remote method call returns as expected") #c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['RMI.DEBUG_FLAG']); ref2 = remote5.__getattr__('m1') ok(ref2 != None,"remote method ref is as expected") #print(RMI.pp.pformat(ref2)); val2b = ref2() is_ok(val2b,"456","remote methodref returns as expected") zz = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['"z"']); is_ok(zz,"z","remote eval works with scalar value"); ''' f1c = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['F1.x1()']) print('f1b: ' + str(f1c)) imp = c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['import F1']) print('imp: ' + str(imp)) ''' # Somehow, closing the connection doesn't cause the server to catch the close, so we have a hack to # signal to it that it should exit. Fix me. c.close c.send_request_and_receive_response('call_function', None, 'RMI.Node._eval', ['"exitnow"']); print("CLIENT DONE")
def function2(x, y): value = F1.run(x, y) return value[1]
def function1(x, y): value = F1.run(x, y) return value[0]
def start(): print '开始参观之旅吧' F1.room1()
import F1 salir = False opcion = 0 import sys user=sys.argv[1] if len(sys.argv)>=2: F1.consultar_orden(user, "EnProceso"); else: print "Este programa necesita un parametro" ~