https://github.com/White-Green/equivoc ‣ Forget this exists • One of the idea that came out of developing this • Make a Programming Language effortless 2
Own Programming Language require "./equivoc" # import something def fma(a, b, c) = a * b + c v = fma(1, 2, 3) e_if v < 0 do # custom if statement v = 0 end 16
Own Programming Language require "./equivoc" def fma(a, b, c) = a * b + c v = fma(1, 2, 3) e_if v < 0 do v = 0 end Run $ ruby ./entry.rb ↓ # easy to create a backend to process this INSTRUCTIONS = [ {tag:"Call",out:"v0",fn:"fma",args:[1, 2, 3]}, {tag:"Le",out:"v1",lhs:"v0",rhs:0}, {tag:"If",cond:"v1", updates:[{"v3","v2","v0"}], then_instr:[ {tag:"Const",out:"v2",value:0}, ],else_instr:[]}, ] 17
Kernel.at_exit do # Called when the program exits # We can use INSTRUCTIONS # INSTRUCTIONS = [ # {tag:"Call",out:"v0",fn:"fma",args:[1, 2, 3]}, # {tag:"Le",out:"v1",lhs:"v0",rhs:0}, # {tag:"If",cond:"v1", # updates:[{"v3","v2","v0"}], # then_instr:[ # {tag:"Const",out:"v2",value:0}, # ],else_instr:[]}, # ] end 32
Kernel.at_exit do # We can process INSTRUCTIONS as we want # e.g. Dump INSTRUCTIONS into filesystem # Spawn backend process and pass INSTRUCTIONS # Process INSTRUCTIONS in Ruby end 33
Own Programming Language require "./equivoc" # the trick is only this! # ...snip... $ ruby entry.rb • collect INSTRUCTIONS like SSA-Form • call backend process (Optimize, Translate and Execute) 34
Own Programming Language require "./equivoc" # the trick is only this! # ...snip... $ ruby entry.rb • collect INSTRUCTIONS like SSA-Form • call backend process (Optimize, Translate and Execute) • Here is Exactly a Programming Language Implementation! ‣ Without parser ‣ Without tree-traversal algorithm • It is enough for testing • Let’s make Programming Language Implementation effortless with Ruby! 35