Skip to content

Commit 111b385

Browse files
timholyJeffBezanson
authored andcommitted
Minor enhancements to devdocs/ast.md (#31032)
1 parent b1acb3c commit 111b385

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

doc/src/devdocs/ast.md

+60-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ Lowered form (IR) is more important to the compiler, since it is used for type i
239239
optimizations like inlining, and and code generation. It is also less obvious to the human,
240240
since it results from a significant rearrangement of the input syntax.
241241

242-
The following data types exist in lowered form:
242+
In addition to `Symbol`s and some number types, the following data
243+
types exist in lowered form:
243244

244245
* `Expr`
245246

@@ -316,7 +317,7 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
316317

317318
Adds a method to a generic function and assigns the result if necessary.
318319

319-
Has a 1-argument form and a 4-argument form. The 1-argument form arises from the syntax `function foo end`.
320+
Has a 1-argument form and a 3-argument form. The 1-argument form arises from the syntax `function foo end`.
320321
In the 1-argument form, the argument is a symbol. If this symbol already names a function in the
321322
current scope, nothing happens. If the symbol is undefined, a new function is created and assigned
322323
to the identifier specified by the symbol. If the symbol is defined but names a non-function,
@@ -325,7 +326,7 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
325326
type uniquely identifies the type to add the method to. When the type has fields, it wouldn't
326327
be clear whether the method was being added to the instance or its type.
327328

328-
The 4-argument form has the following arguments:
329+
The 3-argument form has the following arguments:
329330

330331
* `args[1]`
331332

@@ -345,9 +346,55 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
345346
method to a function that also has methods defined in different scopes) this is an
346347
expression that evaluates to a `:lambda` expression.
347348

349+
* `struct_type`
350+
351+
A 7-argument expression that defines a new `struct`:
352+
353+
* `args[1]`
354+
355+
The name of the `struct`
356+
357+
* `args[2]`
358+
359+
A `call` expression that creates `SimpleVector` specifying its parameters
360+
361+
* `args[3]`
362+
363+
A `call` expression that creates `SimpleVector` specifying its fieldnames
364+
348365
* `args[4]`
349366

350-
`true` or `false`, identifying whether the method is staged (`@generated function`).
367+
A `Symbol` or `GlobalRef` specifying the supertype (e.g., `:Integer` or
368+
`GlobalRef(Core, :Any)`)
369+
370+
* `args[5]`
371+
372+
A `call` expression that creates `SimpleVector` specifying its fieldtypes
373+
374+
* `args[6]`
375+
376+
A Bool, true if `mutable`
377+
378+
* `args[7]`
379+
380+
The number of arguments to initialize. This will be the number
381+
of fields, or the minimum number of fields called by an inner
382+
constructor's `new` statement.
383+
384+
* `abstract_type`
385+
386+
A 3-argument expression that defines a new abstract type. The
387+
arguments are the same as the first three arguments of
388+
`struct_type` expressions.
389+
390+
* `primitive_type`
391+
392+
A 4-argument expression that defines a new primitive type. Arguments 1, 2, and 4
393+
are the same as `struct_type`. Argument 3 is the number of bits.
394+
395+
* `global`
396+
397+
Declares a global binding.
351398

352399
* `const`
353400

@@ -368,6 +415,11 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
368415

369416
Returns its argument as the value of the enclosing function.
370417

418+
* `isdefined`
419+
420+
`Expr(:isdefined, :x)` returns a Bool indicating whether `x` has
421+
already been defined in the current scope.
422+
371423
* `the_exception`
372424

373425
Yields the caught exception inside a `catch` block, as returned by `jl_current_exception()`.
@@ -400,6 +452,10 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
400452
Has the value `false` if inlined into a section of code marked with `@inbounds`,
401453
otherwise has the value `true`.
402454

455+
* `simdloop`
456+
457+
Marks the end of the inner loop of a `@simd` expression.
458+
403459
* `copyast`
404460

405461
Part of the implementation of quasi-quote. The argument is a surface syntax AST that is simply

0 commit comments

Comments
 (0)