Skip to content

Files

executable file
·
21 lines (18 loc) · 1.35 KB

code_elements_header.md

File metadata and controls

executable file
·
21 lines (18 loc) · 1.35 KB
title tags keywords
Code elements
meta-model
code, elements, ast, meta, model

Figure at the end of this page shows the meta model for Java executable code. There are two main kinds of code elements. First, statements CtStatement (javadoc) are untyped top-level instructions that can be used directly in a block of code. Second, expressions CtExpression (javadoc) are used inside the statements. For instance, a CtLoop (javadoc) (which is a statement) points to CtExpression which expresses its boolean condition.

Some code elements such as invocations and assignments are both statements and expressions (multiple inheritance links). Concretely, this is translated as an interface CtInvocation (javadoc) inheriting from both interfaces CtStatement and CtExpression. The generic type of CtExpression is used to add static type-checking when transforming programs.

![Code part of the Spoon Java 8 metamodel]({{ "/images/code-elements.png" | prepend: site.baseurl }})