-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
188 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
#################################|###|##################################### | ||
# __ | | # | ||
# | |--.--.--.----.-----.-----. |===| This file is part of Byron v0.8 # | ||
# | _ | | | _| _ | | |___| An evolutionary optimizer & fuzzer # | ||
# |_____|___ |__| |_____|__|__| ).( https://pypi.org/project/byron/ # | ||
# |_____| \|/ # | ||
################################## ' ###################################### | ||
# Copyright 2023 Giovanni Squillero and Alberto Tonda | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import byron | ||
|
||
|
||
def framework(): | ||
byron.f.set_parameter('_comment', '//') | ||
byron.f.set_option('$dump_node_info', False) | ||
|
||
# The parameter '{_byron}' can be used to get information on the current system. Available fields are: | ||
# 'version', 'system', 'machine', 'python', and 'networkx' | ||
# To get all information use the macro 'byron.f.Info' | ||
|
||
int64 = byron.f.integer_parameter(0, 2**64) | ||
math_op = byron.f.choice_parameter(['+', '-', '*', '/', '&', '^', '|']) | ||
variable = byron.f.macro('var {_node} uint64', _label='') | ||
variable.force_parent('prologue') | ||
|
||
# standard | ||
main_prologue = byron.f.macro('package main\nfunc evolved_function() uint64 {{') | ||
main_prologue.baptize('prologue') | ||
imath = byron.f.macro( | ||
'{var} {op}= {num}', | ||
var=byron.f.global_reference(variable, creative_zeal=1), | ||
op=math_op, | ||
num=int64, | ||
) | ||
vmath = byron.f.macro( | ||
'{var1} = {var2} {op} {var3}', | ||
var1=(byron.f.global_reference(variable, creative_zeal=1, first_macro=True)), | ||
op=math_op, | ||
var2=(byron.f.global_reference(variable)), | ||
var3=(byron.f.global_reference(variable)), | ||
) | ||
|
||
# proc | ||
subs_prologue = byron.f.macro('func {_node}(foo uint64) uint64 {{', _label='') | ||
subs_math = byron.f.macro('foo {op}= {num}', op=math_op, num=int64) | ||
subs_epilogue = byron.f.macro('return foo\n}}') | ||
subs = byron.f.sequence([subs_prologue, byron.f.bunch([subs_math], size=2), subs_epilogue]) | ||
|
||
call = byron.f.macro( | ||
'{var1} = {sub}({var2})', | ||
var1=byron.f.global_reference(variable), | ||
sub=byron.f.global_reference(subs, creative_zeal=1, first_macro=True), | ||
var2=byron.f.global_reference(variable), | ||
) | ||
|
||
code = byron.f.bunch([imath, vmath, call], size=5) | ||
main_epilogue = byron.f.macro('return {var}\n}}', var=byron.f.global_reference(variable)) | ||
return byron.f.sequence((main_prologue, code, main_epilogue), max_instances=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.