Исходный код на Аде

Файл pkg.ads:

package Pkg is
 
type Alpha is abstract tagged record
	data_alpha : Integer;
end record;
procedure func_alpha (x: in out Alpha) is abstract;
 
type Beta is interface;
procedure func_beta (x: in out Beta) is abstract;
 
type Gamma is new Alpha and Beta with record
	data_gamma : Integer;
end record;
procedure func_alpha (x: in out Gamma);
procedure func_beta (x: in out Gamma);
procedure func_gamma (x: in out Gamma);
 
end Pkg;

Файл pkg.adb:

with System.Machine_Code; use System.Machine_Code;
 
package body Pkg is
 
procedure func_gamma (x: in out Gamma) is
begin
	asm ("# func_gamma");
	x.data_gamma := 1;
end func_gamma;
 
procedure func_beta (x: in out Gamma) is
begin
	asm ("# func_beta");
end func_beta;
 
procedure func_alpha (x: in out Gamma) is
begin
	asm ("# func_alpha");
	x.data_alpha := 1;
end func_alpha;
 
end Pkg;

Параметры компиляции

gcc -gnat05 -O -S pkg.adb
Файл gnat.adc:
pragma No_Run_Time;
 
pragma Restrictions (No_Enumeration_Maps);
--  This restriction ensures at compile time that no operations
--  requiring enumeration maps are used (that is Image and Value
--  attributes applied to enumeration types).
 
pragma Restrictions (No_Secondary_Stack);
--  This restriction ensures at compile time that the generated code
--  does not contain any reference to the secondary stack. The
--  secondary stack is used to implement functions returning
--  unconstrained objects (arrays or records) on some targets. The
--  details and use of this restriction are described in more detail
--  in the High Integrity product documentation.
 
pragma Restrictions (Static_Priorities);
--  This restriction ensures at compile time that all priority
--  expressions are static, and that there are no dependencies on the
--  package Ada.Dynamic_Priorities.
 
pragma Restrictions (Static_Storage_Size);
--  This restriction ensures at compile time that any expression
--  appearing in a Storage_Size pragma or attribute definition clause
--  is static.
 
pragma Restrictions (No_Implicit_Heap_Allocations);
-- There are no operations that implicitly require heap storage allocation
-- to be performed by the implementation. The operations that implicitly
-- require heap storage allocation are implementation defined.

Результат на ассемблере

	.file	"pkg.adb"
	.text
.globl pkg__alphaIP
	.type	pkg__alphaIP, @function
pkg__alphaIP:
	pushl	%ebp
	movl	%esp, %ebp
	cmpb	$0, 12(%ebp)
	je	.L4
	movl	pkg__alphaP, %edx
	movl	8(%ebp), %eax
	movl	%edx, (%eax)
.L4:
	popl	%ebp
	ret
	.size	pkg__alphaIP, .-pkg__alphaIP
.globl pkg___alignment
	.type	pkg___alignment, @function
pkg___alignment:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$4, %eax
	popl	%ebp
	ret
	.size	pkg___alignment, .-pkg___alignment
.globl pkg___size
	.type	pkg___size, @function
pkg___size:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$64, %eax
	movl	$0, %edx
	popl	%ebp
	ret
	.size	pkg___size, .-pkg___size
.globl pkg__Oeq
	.type	pkg__Oeq, @function
pkg__Oeq:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movl	4(%eax), %edx
	movl	12(%ebp), %eax
	cmpl	4(%eax), %edx
	sete	%al
	popl	%ebp
	ret
	.size	pkg__Oeq, .-pkg__Oeq
.globl pkg___assign
	.type	pkg___assign, @function
pkg___assign:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%ebx
	movl	8(%ebp), %ecx
	movl	12(%ebp), %ebx
	cmpl	%ebx, %ecx
	je	.L14
	movl	(%ecx), %eax
	movl	(%ebx), %edx
	movl	%edx, (%ecx)
	movl	4(%ebx), %edx
	movl	%edx, 4(%ecx)
	movl	%eax, (%ecx)
.L14:
	popl	%ebx
	popl	%ebp
	ret
	.size	pkg___assign, .-pkg___assign
.globl pkg__betaIP
	.type	pkg__betaIP, @function
pkg__betaIP:
	pushl	%ebp
	movl	%esp, %ebp
	cmpb	$0, 12(%ebp)
	je	.L18
	movl	pkg__betaP, %edx
	movl	8(%ebp), %eax
	movl	%edx, (%eax)
.L18:
	popl	%ebp
	ret
	.size	pkg__betaIP, .-pkg__betaIP
.globl pkg___alignment__2
	.type	pkg___alignment__2, @function
pkg___alignment__2:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$4, %eax
	popl	%ebp
	ret
	.size	pkg___alignment__2, .-pkg___alignment__2
.globl pkg___size__2
	.type	pkg___size__2, @function
pkg___size__2:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$32, %eax
	movl	$0, %edx
	popl	%ebp
	ret
	.size	pkg___size__2, .-pkg___size__2
.globl pkg__Oeq__2
	.type	pkg__Oeq__2, @function
pkg__Oeq__2:
	pushl	%ebp
	movl	%esp, %ebp
	movb	$1, %al
	popl	%ebp
	ret
	.size	pkg__Oeq__2, .-pkg__Oeq__2
.globl pkg___assign__2
	.type	pkg___assign__2, @function
pkg___assign__2:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
	.size	pkg___assign__2, .-pkg___assign__2
.globl pkg___alignment__3
	.type	pkg___alignment__3, @function
pkg___alignment__3:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$4, %eax
	popl	%ebp
	ret
	.size	pkg___alignment__3, .-pkg___alignment__3
.globl pkg__T548s
	.type	pkg__T548s, @function
pkg__T548s:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$4, %esp
	movl	8(%ebp), %eax
	subl	$8, %eax
	movl	%eax, (%esp)
	call	pkg___alignment__3
	leave
	ret
	.size	pkg__T548s, .-pkg__T548s
.globl pkg___size__3
	.type	pkg___size__3, @function
pkg___size__3:
	pushl	%ebp
	movl	%esp, %ebp
	movl	$128, %eax
	movl	$0, %edx
	popl	%ebp
	ret
	.size	pkg___size__3, .-pkg___size__3
.globl pkg__T539s
	.type	pkg__T539s, @function
pkg__T539s:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$4, %esp
	movl	8(%ebp), %eax
	subl	$8, %eax
	movl	%eax, (%esp)
	call	pkg___size__3
	leave
	ret
	.size	pkg__T539s, .-pkg__T539s
.globl pkg__Oeq__3
	.type	pkg__Oeq__3, @function
pkg__Oeq__3:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$16, %esp
	movl	%ebx, -8(%ebp)
	movl	%esi, -4(%ebp)
	movl	8(%ebp), %ebx
	movl	12(%ebp), %esi
	movl	%esi, 4(%esp)
	movl	%ebx, (%esp)
	call	pkg__Oeq
	testb	%al, %al
	je	.L38
	movl	8(%ebx), %eax
	cmpl	8(%esi), %eax
	jne	.L38
	movl	12(%ebx), %eax
	cmpl	12(%esi), %eax
	sete	%al
	jmp	.L41
.L38:
	movb	$0, %al
.L41:
	movl	-8(%ebp), %ebx
	movl	-4(%ebp), %esi
	movl	%ebp, %esp
	popl	%ebp
	ret
	.size	pkg__Oeq__3, .-pkg__Oeq__3
.globl pkg__T557s
	.type	pkg__T557s, @function
pkg__T557s:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	movl	12(%ebp), %eax
	movl	%eax, 4(%esp)
	movl	8(%ebp), %eax
	subl	$8, %eax
	movl	%eax, (%esp)
	call	pkg__Oeq__3
	leave
	ret
	.size	pkg__T557s, .-pkg__T557s
.globl pkg___assign__3
	.type	pkg___assign__3, @function
pkg___assign__3:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%ebx
	movl	8(%ebp), %ecx
	movl	12(%ebp), %ebx
	cmpl	%ebx, %ecx
	je	.L48
	movl	(%ecx), %edx
	movl	(%ebx), %eax
	movl	%eax, (%ecx)
	movl	4(%ebx), %eax
	movl	%eax, 4(%ecx)
	movl	8(%ebx), %eax
	movl	%eax, 8(%ecx)
	movl	12(%ebx), %eax
	movl	%eax, 12(%ecx)
	movl	%edx, (%ecx)
.L48:
	popl	%ebx
	popl	%ebp
	ret
	.size	pkg___assign__3, .-pkg___assign__3
.globl pkg__T566s
	.type	pkg__T566s, @function
pkg__T566s:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	movl	12(%ebp), %eax
	movl	%eax, 4(%esp)
	movl	8(%ebp), %eax
	subl	$8, %eax
	movl	%eax, (%esp)
	call	pkg___assign__3
	leave
	ret
	.size	pkg__T566s, .-pkg__T566s
.globl pkg__func_gamma
	.type	pkg__func_gamma, @function
pkg__func_gamma:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_gamma
#NO_APP
	movl	8(%ebp), %eax
	movl	$1, 12(%eax)
	popl	%ebp
	ret
	.size	pkg__func_gamma, .-pkg__func_gamma
.globl pkg__func_beta__2
	.type	pkg__func_beta__2, @function
pkg__func_beta__2:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_beta
#NO_APP
	popl	%ebp
	ret
	.size	pkg__func_beta__2, .-pkg__func_beta__2
.globl pkg__T578s
	.type	pkg__T578s, @function
pkg__T578s:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
	.size	pkg__T578s, .-pkg__T578s
.globl pkg__func_alpha__2
	.type	pkg__func_alpha__2, @function
pkg__func_alpha__2:
	pushl	%ebp
	movl	%esp, %ebp
#APP
	# func_alpha
#NO_APP
	movl	8(%ebp), %eax
	movl	$1, 4(%eax)
	popl	%ebp
	ret
	.size	pkg__func_alpha__2, .-pkg__func_alpha__2
.globl pkg___elabs
	.type	pkg___elabs, @function
pkg___elabs:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	pushl	%ebx
	movb	$1, pkg__alphaT
	movb	$2, pkg__alphaT+1
	cmpb	$0, pkg__alphaF
	je	.L60
	movl	pkg__alphaP, %eax
	movl	$pkg__alphaB, -4(%eax)
	movl	pkg__alphaP, %eax
	cmpb	$2, -11(%eax)
	jne	.L62
	movl	-4(%eax), %eax
	movl	$16, 28(%eax)
	jmp	.L64
.L62:
	movl	-4(%eax), %eax
	movl	$16, 4(%eax)
.L64:
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__alphaE, 8(%eax)
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movl	$0, 4(%eax)
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movl	$0, (%eax)
	movl	$0, 32(%eax)
	movl	pkg__alphaP, %edx
	movl	%edx, 40(%eax)
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movl	$0, 24(%eax)
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movb	$0, 20(%eax)
	movl	pkg__alphaP, %eax
	movl	$0, -8(%eax)
	movl	pkg__alphaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__alphaE, 12(%eax)
	movb	$0, pkg__alphaF
.L60:
	movl	pkg__alphaP, %eax
	movl	$pkg___size, (%eax)
	movl	pkg__alphaP, %eax
	movl	$pkg___alignment, 4(%eax)
	movl	pkg__alphaP, %eax
	movl	$pkg__Oeq, 24(%eax)
	movl	pkg__alphaP, %eax
	movl	$pkg___assign, 28(%eax)
	movb	$1, pkg__betaT
	movb	$4, pkg__betaT+1
	cmpb	$0, pkg__betaF
	je	.L65
	movl	pkg__betaP, %eax
	movl	$pkg__betaB, -4(%eax)
	movl	pkg__betaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__betaE, 8(%eax)
	movl	pkg__betaP, %eax
	movl	-4(%eax), %eax
	movl	$0, (%eax)
	movl	$0, 32(%eax)
	movl	pkg__betaP, %edx
	movl	%edx, 40(%eax)
	movl	pkg__betaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__betaE, 12(%eax)
	movb	$0, pkg__betaF
.L65:
	movb	$1, pkg__T281s
	movb	$3, pkg__T281s+1
	movl	$1, pkg__I282s
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__I282s, -4(%eax)
	movl	pkg__pkg__gamma0P, %eax
	cmpb	$2, -11(%eax)
	jne	.L67
	movl	-4(%eax), %eax
	movl	$16, 28(%eax)
	jmp	.L69
.L67:
	movl	-4(%eax), %eax
	movl	$16, 4(%eax)
.L69:
	movb	$1, pkg__gammaT
	movb	$2, pkg__gammaT+1
	cmpb	$0, pkg__gammaF
	je	.L70
	movl	pkg__gammaP, %eax
	movl	$pkg__gammaB, -4(%eax)
	movl	pkg__gammaP, %eax
	cmpb	$2, -11(%eax)
	jne	.L72
	movl	-4(%eax), %eax
	movl	$18, 28(%eax)
	jmp	.L74
.L72:
	movl	-4(%eax), %eax
	movl	$18, 4(%eax)
.L74:
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__gammaE, 8(%eax)
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %eax
	movl	$0, 4(%eax)
	movl	pkg__alphaP, %esi
	testl	%esi, %esi
	je	.L75
	movl	pkg__gammaP, %edi
	cld
	movl	$16, %ecx
	rep
	movsl
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %esi
	movl	pkg__alphaP, %eax
	testl	%eax, %eax
	je	.L77
	movl	-4(%eax), %edi
	movl	(%edi), %eax
	incl	%eax
	movl	%eax, (%esi)
	movl	32(%edi), %eax
	movl	%eax, 32(%esi)
	addl	(%esi), %eax
	movl	(%edi), %ebx
	movl	32(%edi), %ecx
	testl	%eax, %eax
	jle	.L79
	movl	%eax, %edx
	leal	(%ebx,%ecx), %ecx
.L81:
	movl	40(%edi,%ecx,4), %eax
	movl	%eax, 40(%esi,%edx,4)
	decl	%ecx
	decl	%edx
	je	.L79
	jmp	.L81
.L77:
	movl	$0, (%esi)
	movl	$0, 32(%esi)
.L79:
	movl	pkg__gammaP, %eax
	movl	%eax, 40(%esi)
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %eax
	movl	$0, 24(%eax)
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %eax
	movb	$0, 20(%eax)
	movl	pkg__gammaP, %eax
	movl	$0, -8(%eax)
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %eax
	movl	$pkg__gammaE, 12(%eax)
	movb	$0, pkg__gammaF
.L70:
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %edi
	movl	32(%edi), %ebx
	testl	%ebx, %ebx
	jle	.L82
	movl	(%edi), %eax
	leal	1(%eax), %edx
	leal	(%ebx,%eax), %esi
	movl	pkg__betaP, %ecx
	leal	40(%edi,%eax,4), %eax
.L84:
	cmpl	%ecx, 4(%eax)
	je	.L85
	incl	%edx
	addl	$4, %eax
	cmpl	%esi, %edx
	jle	.L84
.L82:
	leal	1(%ebx), %eax
	movl	%eax, 32(%edi)
	addl	(%edi), %eax
	movl	pkg__betaP, %edx
	movl	%edx, 40(%edi,%eax,4)
.L85:
	movl	pkg__gammaP, %eax
	movl	$pkg___size__3, (%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__T539s, (%eax)
	movl	pkg__gammaP, %eax
	movl	$pkg___alignment__3, 4(%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__T548s, 4(%eax)
	movl	pkg__gammaP, %eax
	movl	$pkg__Oeq__3, 24(%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__T557s, 24(%eax)
	movl	pkg__gammaP, %eax
	movl	$pkg___assign__3, 28(%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__T566s, 28(%eax)
	movl	pkg__gammaP, %eax
	movl	$pkg__func_beta__2, 64(%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	$pkg__T578s, 60(%eax)
	movl	pkg__pkg__gamma0P, %eax
	movl	pkg__gammaP, %esi
	testl	%esi, %esi
	je	.L87
	cld
	movl	$15, %ecx
	movl	%eax, %edi
	rep
	movsl
.L87:
	movl	pkg__gammaP, %eax
	movl	$pkg__func_alpha__2, 60(%eax)
	movl	pkg__gammaP, %eax
	movl	$pkg__func_gamma, 68(%eax)
	popl	%ebx
	popl	%esi
	popl	%edi
	popl	%ebp
	ret
.L75:
	movl	pkg__gammaP, %eax
	movl	-4(%eax), %esi
	jmp	.L77
	.size	pkg___elabs, .-pkg___elabs
.globl pkg__gammaIP
	.type	pkg__gammaIP, @function
pkg__gammaIP:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %edx
	cmpb	$0, 12(%ebp)
	je	.L92
	movl	pkg__gammaP, %eax
	movl	%eax, (%edx)
.L92:
	movl	pkg__pkg__gamma0P, %eax
	movl	%eax, 8(%edx)
	movl	pkg__pkg__gamma0P, %eax
	movl	$8, -8(%eax)
	popl	%ebp
	ret
	.size	pkg__gammaIP, .-pkg__gammaIP
.globl pkg_E
	.data
	.type	pkg_E, @object
	.size	pkg_E, 1
pkg_E:
	.zero	1
.globl pkg__alphaT
	.bss
	.align 32
	.type	pkg__alphaT, @object
	.size	pkg__alphaT, 76
pkg__alphaT:
	.zero	76
.globl pkg__alphaP
	.data
	.align 4
	.type	pkg__alphaP, @object
	.size	pkg__alphaP, 4
pkg__alphaP:
	.long	pkg__alphaT+12
.globl pkg__alphaF
	.type	pkg__alphaF, @object
	.size	pkg__alphaF, 1
pkg__alphaF:
	.byte	1
.globl pkg__alphaB
	.bss
	.align 32
	.type	pkg__alphaB, @object
	.size	pkg__alphaB, 44
pkg__alphaB:
	.zero	44
.globl pkg__alphaE
	.data
	.type	pkg__alphaE, @object
	.size	pkg__alphaE, 10
pkg__alphaE:
	.string	"PKG.ALPHA"
.globl pkg__betaT
	.bss
	.align 4
	.type	pkg__betaT, @object
	.size	pkg__betaT, 16
pkg__betaT:
	.zero	16
.globl pkg__betaP
	.data
	.align 4
	.type	pkg__betaP, @object
	.size	pkg__betaP, 4
pkg__betaP:
	.long	pkg__betaT+12
.globl pkg__betaF
	.type	pkg__betaF, @object
	.size	pkg__betaF, 1
pkg__betaF:
	.byte	1
.globl pkg__betaB
	.bss
	.align 32
	.type	pkg__betaB, @object
	.size	pkg__betaB, 40
pkg__betaB:
	.zero	40
.globl pkg__betaE
	.data
	.type	pkg__betaE, @object
	.size	pkg__betaE, 9
pkg__betaE:
	.string	"PKG.BETA"
.globl pkg__T281s
	.bss
	.align 32
	.type	pkg__T281s, @object
	.size	pkg__T281s, 76
pkg__T281s:
	.zero	76
.globl pkg__pkg__gamma0P
	.data
	.align 4
	.type	pkg__pkg__gamma0P, @object
	.size	pkg__pkg__gamma0P, 4
pkg__pkg__gamma0P:
	.long	pkg__T281s+12
.globl pkg__I282s
	.bss
	.align 4
	.type	pkg__I282s, @object
	.size	pkg__I282s, 12
pkg__I282s:
	.zero	12
.globl pkg__gammaT
	.align 32
	.type	pkg__gammaT, @object
	.size	pkg__gammaT, 84
pkg__gammaT:
	.zero	84
.globl pkg__gammaP
	.data
	.align 4
	.type	pkg__gammaP, @object
	.size	pkg__gammaP, 4
pkg__gammaP:
	.long	pkg__gammaT+12
.globl pkg__gammaF
	.type	pkg__gammaF, @object
	.size	pkg__gammaF, 1
pkg__gammaF:
	.byte	1
.globl pkg__gammaB
	.bss
	.align 32
	.type	pkg__gammaB, @object
	.size	pkg__gammaB, 52
pkg__gammaB:
	.zero	52
.globl pkg__gammaE
	.data
	.type	pkg__gammaE, @object
	.size	pkg__gammaE, 10
pkg__gammaE:
	.string	"PKG.GAMMA"
	.ident	"GCC: (GNU) 4.1.1"
	.section	.note.GNU-stack,"",@progbits
 
proj/lang/gamma-ada.txt · Последние изменения: 2006/06/13 10:50
 
Copyright (C) 1996-2013 Serge Vakulenko
serge@vak.ru