Answered step by step
Verified Expert Solution
Link Copied!

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) image text in transcribed

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 value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago