Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Based on single static program (SSA) Inside compilers we sometimes programs in a high-level language like Java or Erlang into programs in a much simpler
Based on single static program (SSA)
Inside compilers we sometimes programs in a high-level language like Java or Erlang into programs in a much simpler language called static single example of an SSA program. (SSA) programs. Here is an b := a+2; Each statement is an assignment to a variable, and on the right hand side there can be one of three things - an integer constant (like 3) - a variable (like a) an application of a binary operator +or *) to two arguments that are either constants or 2.1 Explain, either informally or by writing some type declarations, how you would represent SSA statements and programs in Erlang 2.2 Define a function run that takes an SSA program P and an environment E associating values with variables, that runs the program P in that environment, producing a new environment. For example, running the program above in an empty environment results in an environment where a has the value 3, b has the value 5 and c has the value 25 To be a valid SSA program, a variable must have a value before it can be used on the right-hand side of an assignment, and each variable can only be assigned to once 2.3 Define a function unique that takes an SSA program and checks that each variable is only assigned to once 2.4 Define a function defined that takes an SSA program and checks that each variable has a value before it is used on the right-hand side of an assignment. 2.5 Define a function translate_expr that takes an arbitrary expression from the expr.erl program and converts it to SSA form, so that in the final environment after it is run, there is a variable with its value Inside compilers we sometimes programs in a high-level language like Java or Erlang into programs in a much simpler language called static single example of an SSA program. (SSA) programs. Here is an b := a+2; Each statement is an assignment to a variable, and on the right hand side there can be one of three things - an integer constant (like 3) - a variable (like a) an application of a binary operator +or *) to two arguments that are either constants or 2.1 Explain, either informally or by writing some type declarations, how you would represent SSA statements and programs in Erlang 2.2 Define a function run that takes an SSA program P and an environment E associating values with variables, that runs the program P in that environment, producing a new environment. For example, running the program above in an empty environment results in an environment where a has the value 3, b has the value 5 and c has the value 25 To be a valid SSA program, a variable must have a value before it can be used on the right-hand side of an assignment, and each variable can only be assigned to once 2.3 Define a function unique that takes an SSA program and checks that each variable is only assigned to once 2.4 Define a function defined that takes an SSA program and checks that each variable has a value before it is used on the right-hand side of an assignment. 2.5 Define a function translate_expr that takes an arbitrary expression from the expr.erl program and converts it to SSA form, so that in the final environment after it is run, there is a variable with its valueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started