Overview of Intermediate Code - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Overview of Intermediate Code Structure

Description

• 

Input to CodeGeneration is first transformed to Intermediate Code, an expression consisting of nested unevaluated function calls, which represents a simplified form of the input.

• 

The Intermediate Code is the basic structure on which both built-in and user-created translators operate.  The names of the functions used in Intermediate Code expressions are members of the CodeGeneration,Names subpackage.

• 

The following table lists the names used in Intermediate Code.

And

ArrayAssignment

ArrayIndices

ArrayInitialization

ArrayRanges

ArrayType

ArrayVariable

AssignedName

Assignment

Break

Coercion

ConditionalPair

Declaration

DescriptionSequence

Equal

Error

ExportSequence

Expression

ExpressionSequence

Float

ForFromLoop

FunctionCall

GeneratedName

GlobalSequence

If

Integer

Inverse

Less

LessEqual

LexicalSequence

List

ListArray

LocalSequence

Module

ModuleDefinition

Name

Negation

Next

Not

NotEqual

OptionSequence

Or

ParameterSequence

Power

Procedure

Product

Range

Rational

Return

ReturnVariableName

Scope

Statement

StatementSequence

String

Sum

Try

Type

Values

WhileLoop

 

• 

The form and purpose of each of the Intermediate Code names is explained in detail in the following table.  The names arg1, arg2, ... refer to the required arguments as given under Form.

Name

Form

Description

And

And(Expression, Expression)

The logical expression, "arg1 and

 

 

arg2".

 

 

 

Array

Array(

An array, where arg1 is the ranges of

 

ArrayRanges, Values(

the array, and arg2 contains the

 

{ArrayIndices=Expression}+))

values which it holds.

 

 

 

ArrayAssignment

ArrayAssignment(Expression,

Assignment of one array to another

 

Expression,

array, where arg1 is the name of

 

list({ArrayIndices}+))

the first array, arg2 is the name

 

 

of the second array, and arg3 is a

 

 

list of indices necessary for

 

 

element-wise assignments.

 

 

 

ArrayIndices

ArrayIndices({Expression}+)

An index to an array element; the

 

 

arguments are a sequence of indices

 

 

whose number corresponds to the

 

 

dimension of the array.

 

 

 

ArrayInitialization

ArrayInitialization(

Assignment of multiple values to an

 

Expression, Array)

array, where arg1 and arg2 are the

 

 

name and ranges of the target array,

 

 

and arg3 contains the values

 

 

corresponding to each set of indices.

 

 

 

ArrayRanges

ArrayRanges({range}+)

Ranges associated with an array.

 

 

 

ArrayType

ArrayType(Type, ArrayRanges)

An array type, where arg1 is the

 

 

element type and arg2 contains the

 

 

ranges of the array.

 

 

 

ArrayVariable

ArrayVariable(Expression,

An array element, where arg1 is the

 

ArrayIndices)

name of the array, and arg2 is the

 

 

index of this array element.

 

 

 

AssignedName

AssignedName(

An assigned name, where arg1 is

 

{Name | GeneratedName},

the name and arg2 is the value.

 

Expression)

 

 

 

 

Assignment

Assignment(Expression,

An assignment of arg2 to arg1.

 

Expression)

 

 

 

 

Break

Break()

A break statement, that is, an

 

 

instruction to jump to the end of the

 

 

current ForFromLoop or WhileLoop

 

 

structure.

 

 

 

Coercion

Coercion(Expression, Type)

A coercion of arg1 to type arg2.

 

 

 

ConditionalPair

ConditionalPair(Expression,

A conditional pair, where arg1 is a

 

StatementSequence)

condition and arg2 is the statement

 

 

sequence to be executed if the

 

 

condition is true.

 

 

 

Declaration

Declaration(Name,

A declaration that arg1 has type arg2.

 

Type | ArrayType)

 

 

 

 

DescriptionSequence

DescriptionSequence(

A sequence of descriptions.

 

{Expression}*)

 

 

 

 

Equal

Equal(Expression, Expression)

The relation "arg1 = arg2".

 

 

 

Error

Error(string,

A error statement; arg1 is a format

 

list({Expression}+)

string similar to that used by the

 

 

Maple error command; arg2 is a list

 

 

of expressions to be substituted

 

 

into numbered parameter locations

 

 

in arg1.

 

 

 

ExportSequence

ExportSequence({Declaration}*)

A sequence of exported variables.

 

 

 

Expression

And | ArrayVariable |

An expression.

 

AssignedName |

 

 

Coercion | Equal |

 

 

ExpressionSequence |

 

 

Float |

 

 

FunctionCall |

 

 

GeneratedName |

 

 

Integer | Inverse |

 

 

Less | LessEqual |

 

 

List | ListArray |

 

 

Name | Negation | Not |

 

 

NotEqual | Or | Power |

 

 

Product | Range|

 

 

Rational | String | Sum

 

 

 

 

ExpressionSequence

ExpressionSequence(

A sequence of expressions; arg1 is a

 

{Expression}*)

list containing these expressions.

 

 

 

Float

Float(nonnegint,

A positive floating-point number,

 

integer)

where arg1 and arg2 are the mantissa

 

 

and exponent respectively.

 

 

 

ForFromLoop

ForFromLoop(Expression,

A "for" (counter-controlled) loop.

 

Expression, Expression,

The arguments represent the loop

 

Expression,

counter, the start value, the step

 

StatementSequence)

and the end value, respectively;

 

 

arg5 is the body of the loop.

 

 

 

FunctionCall

FunctionCall(Name,

A function call, where arg1 is the

 

ExpressionSequence, funcsig)

name of the function, arg2 is an

 

 

expression sequence containing the

 

 

arguments, and arg3 is the function

 

 

signature having the form

 

 

 

GeneratedName

GeneratedName(string)

A name generated by Maple.

 

 

 

GlobalSequence

GlobalSequence({Declaration}*)

A sequence of global variables.

 

 

 

If

If({ConditionalPair,

An "if" statement, where arg1 is a

 

StatementSequence}*)

list of conditional pairs which

 

 

correspond to "if" and "else if"

 

 

clauses and arg2 (optional) is the

 

 

body of the "else" clause.

 

 

 

Integer

Integer(nonnegint)

A non-negative integer.

 

 

 

Inverse

Inverse(Expression, name)

The inverse of an expression,

 

 

that is, 1/arg1; arg2 is the type of

 

 

the expression (integer or numeric).

 

 

 

Less

Less(Expression, Expression)

The relation, "arg1 < arg2".

 

 

 

LessEqual

LessEqual(Expression,

The relation, "arg1 <= arg2".

 

Expression)

 

 

 

 

LexicalSequence

LexicalSequence({Declaration}*)

A sequence of lexical variables.

 

 

 

List

List({Expression}*)

A list of expressions.

 

 

 

ListArray

ListArray({Expression}*)

A list of expressions.

 

 

 

LocalSequence

LocalSequence({Declaration}*)

A sequence of local variables.

 

 

 

Module

Module(ExpressionSequence,

A module. arg1 is an exprseq of

 

ModuleDefinition,

a list of instantiated exports, arg2

 

ExpressionSequence)

a is the module definition, and arg3

 

 

is an exprseq of instantiated local

 

 

variables.

 

 

 

ModuleDefinition

ModuleDefinition(

A module definition:

 

ParameterSequence,

arg1 holds the formal parameters,

 

LocalSequence,

arg2 the module local variables,

 

OptionSequence,

arg3 the module options,

 

ExportSequence,

arg4 the module exports,

 

StatementSequence,

arg5 the body,

 

DescriptionSequence,

arg6 the description string,

 

GlobalSequence,

arg7 the global variables,

 

LexicalSequence,

arg8 the lexical table,

 

Expression)

arg9 the formal module name

 

 

(if the module is named).

 

 

 

Name

Name(string)

A name.

 

 

 

Negation

Negation(Expression)

The negation of arg1.

 

 

 

Next

Next()

A next statement, that is, an

 

 

instruction to jump to the start of

 

 

the current ForFromLoop or

 

 

WhileLoop structure, incrementing the

 

 

loop counter in the case of a

 

 

ForFromLoop.

 

 

 

Not

Not(Expression)

The logical expression, "not arg1".

 

 

 

NotEqual

NotEqual(Expression,

The relation, "arg1 <> arg2".

 

Expression)

 

 

 

 

OptionSequence

OptionSequence({Name}*)

A sequence of procedure/module

 

 

options.

 

 

 

Or

Or(Expression, Expression)

The logical expression, "arg1 or

 

 

arg2".

 

 

 

ParameterSequence

ParameterSequence(

A sequence of parameters.

 

{Declaration}*)

 

 

 

 

Power

Power(Expression, Expression)

The expression, "arg1 raised to the

 

 

power arg2".

 

 

 

Procedure

Procedure(

A procedure:

 

ParameterSequence,

arg1 holds the formal parameters,

 

LocalSequence,

arg2 the local variables,

 

OptionSequence,

arg3 the procedure options,

 

Expression,

arg4 the remember table,

 

StatementSequence,

arg5 the procedure body,

 

DescriptionSequence,

arg6 the description string,

 

GlobalSequence,

arg7 the global variables,

 

LexicalSequence,

arg8 the lexical table,

 

Type)

arg9 the return type.

 

 

 

Product

Product({Expression}+)

A product of terms.

 

 

 

Range

Range({range}+)

A sequence of ranges.

 

 

 

Rational

Rational(posint, posint)

A positive rational number,

 

 

arg1/arg2.

 

 

 

Return

Return(Expression)

A return statement, where arg1 is

 

 

the expression to be returned.

 

 

 

ReturnVariableName

ReturnVariableName()

structure used to represent the name

 

 

of the return variable, if present

 

 

 

Scope

Scope(symboltables, icode)

data structure for a complete IC

 

 

including symbol tables

 

 

 

Statement

Statement(Expression)

An expression that is also a complete

 

 

statement.

 

 

 

StatementSequence

StatementSequence(

A sequence of statements.

 

{Statement, Assignment,

 

 

Error, ForFromLoop, If,

 

 

Return, WhileLoop}*)

 

 

 

 

String

String(string)

A string.

 

 

 

Sum

Sum({Expression}+))

A sum of terms.

 

 

 

Try

Try(StatementSequence,

A try/catch/finally block. arg1 is the

 

{Expression |

try block, arg2 is the catch block.

 

StatementSequence}*)

 

 

 

 

Type

Type(name)

A type name.

 

 

 

Values

Values({Expression}+)

container for array values

 

 

 

WhileLoop

WhileLoop(Expression,

A "while" (condition-controlled) loop,

 

StatementSequence)

where arg1 is the condition and arg2

 

 

is the body of the loop.

See Also

CodeGeneration,Names

IntermediateCode

LanguageDefinition