home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
PROG
/
PASCAL
/
SPEED2
/
DOC
/
LANGREF.DOC
< prev
next >
Wrap
Text File
|
1994-10-03
|
42KB
|
981 lines
----------------------------------------------------------------------------
SPEED-Pascal/2 V1.0 for OS/2 Language reference
----------------------------------------------------------------------------
by: Rene Nürnberger (the author of SPEED-Pascal/2 itself !)
Special thanks to Jörg Braun and Wolfhard Rinke from the
"toolbox" magazine for all their help.
**************************************
NOTE: This file is only a "fragment" !
**************************************
CONTENTS
Chapter 1. Introduction and Basic Elements of SPEED-Pascal/2 .......
Introduction .....................................................
Who should read this book ? ......................................
System requirements ..............................................
Character set ....................................................
Identifiers ......................................................
Reserved Words ...................................................
Comments .........................................................
Chapter 2. Structure of SPEED-Pascal/2 Programs ....................
Overview .........................................................
Basic structure of a SPEED-Pascal/2 Program ......................
Using the syntax description .....................................
Description of the SPEED-Pascal/2 Grammar ........................
Chapter 3. Declarations ............................................
Overview .........................................................
CONST Declaration ................................................
VAR Declaration ..................................................
TYPE Declaration .................................................
LABEL Declaration ................................................
Chapter 4. Data types...............................................
Overview .........................................................
Predefined data types ............................................
Defining your own data types .....................................
Type compatibility ...............................................
ARRAY Data Type ..................................................
BOOLEAN Data Type ................................................
BYTE Data Type ...................................................
CHAR Data Type ...................................................
DOUBLE Data Type .................................................
Enumeration Data Type ............................................
EXTENDED Data Type ...............................................
FILE Data Type ...................................................
INTEGER Data Type ................................................
LONGINT Data Type ................................................
LONGWORD Data Type ...............................................
POINTER Data Type ................................................
REAL Data Type ...................................................
SET Data Type ....................................................
SHORTINT Data Type ...............................................
TEXT Data Type ...................................................
WORD Data Type ...................................................
Chapter 5. Procedures and functions
Overview .........................................................
PROCEDURE Definition .............................................
FUNCTION Definition ..............................................
MACRO Definition .................................................
Parameterlists ...................................................
Pass by Value Parameters .........................................
Pass by Reference Parameters .....................................
Returning function results .......................................
Using libaries ...................................................
Using Dynamic link libraries (DLL's) .............................
Calling Procedures ...............................................
Calling Functions ................................................
Calling Macros ...................................................
Calling DLL Procedures and Functions .............................
Chapter 6. Expressions .............................................
Overview .........................................................
Boolean Expressions ..............................................
Numeric expressions ..............................................
Set expressions ..................................................
String expressions ...............................................
Other expressions ................................................
AND Operators ....................................................
Addition Operators ...............................................
Multiplication Operators .........................................
NOT Operators ....................................................
Relational Operators .............................................
Function Calls ...................................................
SET operators ....................................................
Chapter 7. Statements ..............................................
Overview ..........................................................
ASM Statement .....................................................
ASSEMBLER Statement ...............................................
Assignment Statement ..............................................
BEGIN (Compound) Statement ........................................
CASE Statement ....................................................
Empty Statement ...................................................
FOR Statement .....................................................
Function Call .....................................................
GOTO Statement ....................................................
IF Statement ......................................................
Procedure Call ....................................................
REPEAT Statement ..................................................
WHILE Statement ...................................................
WITH Statement ....................................................
Chapter 8. OOP Extensions to SPEED-Pascal/2.........................
Overview ..........................................................
Understanding OOP .................................................
Objects Methods and Variables .....................................
OBJECT Definition .................................................
CONSTRUCTOR Definition ............................................
DESTRUCTOR Definition .............................................
Using Objects .....................................................
Using Virtual Methods .............................................
Chapter 10. Using DLL's with SPEED-Pascal/2 .........................
Overview ..........................................................
IMPORTS statement .................................................
EXPORTS statement .................................................
Creating your own DLL's ...........................................
Parameterlist Conversion in C functions ...........................
Chapter 11. Using libraries with SPEED-Pascal/2 .....................
Overview ..........................................................
INTERFACE section of a library ....................................
IMPLEMENTATION section of a library ...............................
USES keyword ......................................................
Using standard libraries ..........................................
Creating your own libraries........................................
Using your own libraries ..........................................
Libraries versus DLL's ............................................
Chapter 12. Advanced topics .........................................
Using Inline Assembler ............................................
Calling DLL's from Assembler ......................................
Binding External Assembler Modules ................................
Using large Memory Pools...........................................
Chapter 13 Internal details..........................................
VMT and DMT Table layout...........................................
Using the Compiler/Assembler/Resource Compiler as DLL's............
Appendix ............................................................
SPEED-Pascal/2 Error Messages .....................................
SPEED-ASM Error Messages ..........................................
Compiler Directives ...............................................
Chapter 1. Introduction and Basic Elements of SPEED-Pascal/2
============================================================
Introduction
------------
SPEED-Pascal/2 is a 32 Bit Pascal Compiler for OS/2. It produces real fast
EXE's and uses most of the features of OS/2 since version 2.1 including
Multihreading and 32 Bit Memory Management.
SPEED-Pascal/2 is up to 99 per cent Turbo-Pascal compatible. That means you
can use your old Pascal Sources and simply recompile them under OS/2.
For creating new programs you can use the newly developed Object-PM
library and take advantage of the OS/2 Presentation Manager under the
hood of an object-oriented library.
SPEED-Pascal/2 is a true 32 Bit Compiler. That means the generated code
is optimized for at least a 386-Processor. There are no longer barriers
of 64K segments in SPEED-Pascal because all Data Objects are referenced
over 32 Bit Pointers. Since that SPEED-Pascal requires as a minimum a
80386SX Processor and OS/2 2.1 (See "System Requirements").
SPEED-Pascal/2 comes along with several Standard libraries that can be used
to easily access all basic features of OS/2 including File Management
and Screen output. The Object oriented library Object-PM provides an
object oriented user interface to cummunicate with the OS/2 Presentation
Manager.
The Programs generated with SPEED-Pascal need no external libraries to
run except the DLL's you import in your Program (and of course you can build
your own DLL's).
The compiler comes as Command-line version and as the Integrated Development
Environment (IDE). It's strongly recommended that you use the IDE to
develop your programs. Under the hood of the IDE several programs are
integrated such as:
* The SPEED-Pascal/2 Compiler itself
* The SPEED-Asm Assembler
* The Speed-Resource Compiler
* The Speed-Resource Editor
* The Help Precompiler
* An Editor
* A Context sensitive help system
If you have ideas for further versions of SPEED-Pascal/2 or you may find bugs
please send E-Mail via Compuserve to 72662,2052.
Who should read this book ?
---------------------------
This book is NOT a learner's guide. It's to be used by people who are
always familiar with the PASCAL language and programming in high level
languages. Refer to "SPEED-Pascal/2 Programming reference" for more
information about programming.
This book provides the full definition of the SPEED-Pascal/2 Programming
language and its syntax. It can also be used as a quick reference since
all elements of the SPEED-Pascal language are discussed.
System requirements
-------------------
SPEED-Pascal/2 requires at least a 80386SX Processor with a minimum of 4 MB
RAM and OS/2 2.1 (or higher) running on it. It's strongly recommended to have
a minimum of 8 MB RAM for compiling large projects. The compiler would also
run with 4 MB memory but compile speed can slow down rapidly.
SPEED-Pascal/2 requires for installation a minimum of about 10 MB Hard disk
space. IF you disable installing several components of SPEED-Pascal this
can be reduced down to 5 MB.
It's recommended to have after the installation at least 5 MB of Hard disk
space free for compiling your own projects.
Character set
-------------
The following characters are known to the compiler. Other characters cannot
be used inside of your SPEED-Pascal programs except those used in character
strings.
Character set:
!&'()*+,-/0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnop
qrstuvwxyz{|}
Identifiers
-----------
Identifiers in SPEED-Pascal/2 can be an expression that meets the following
rules:
* Identifiers can be at least 32 characters long
* An Identifier MUST start with a letter or an underscore ("_" char).
After the first letter the following chars CAN follow (also multiple
times) :
- a letter
- a digit
- an underscore
If the Identifier starts with an underscore ("_" char), a minimum of
one letter must follow.
* An Identifier must completely fit in one source code line
SPEED-Pascal/2 doesn't distingish between uppercase and lowercase. That means
the identifiers "ident","Ident" and "IDENT" or even "IdeNt" are aquivalent.
In SPEED-Pascal/2 two types of identifiers are valid:
* Predefined Identifiers (cannot be redefined or used in other context)
* User defined Identifiers (are declared by you as the programmer)
Examples for valid Identifiers:
Ident
Ident1
_m
_M1
MyVar
Reserved Words
--------------
Reserved words are predefined identifiers that are used by SPEED-Pascal as
tokens. Reserved words cannot be redeclared or used in another context
than those described in the Grammar of SPEED-Pascal (see "Description of the
SPEED-Pascal/2 Grammar").
SPEED-Pascal/2 doesn't distingish between uppercase and lowercase. That means
the reserved words "begin","Begin" and "BEGIN" or even "BeGin" are
aquivalent.
Reserved words in SPEED-Pascal are:
┌─────────────────────────────────────────────────────────────────────┐
│ ABS ADDR AND ARCTAN ARRAY │
│ ASM ASSEMBLER BEGIN CASE CDECL │
│ CHR CONST CONSTRUCTOR COS DEC │
│ DESTRUCTOR DIV DO DOWNTO ELSE │
│ END EXIT EXP EXPORTS FALSE │
│ FILE FOR FORWARD FRAC FUNCTION │
│ GOTO HI IF IMPLEMENTATION IMPORTS │
│ IN INC INDEX INLINE INT │
│ INTERFACE LABEL LENGTH LIBRARY LN │
│ LO MACRO MOD NIL NOT │
│ OBJECT OF OR ORD PRED │
│ PROCEDURE PROGRAM PTR READ READLN │
│ RECORD REPEAT RESOURCE ROUND RUNERROR │
│ SET SHL SHR SIN SIZEOF │
│ SQR SQRT STRING SUCC TEXT │
│ THEN TO TRUE TRUNC TYPE │
│ UNIT UNTIL USES VAR VIRTUAL │
│ WHILE WITH WRITE WRITELN XOR │ │
└─────────────────────────────────────────────────────────────────────┘
Comments
--------
Comments are remarks by the programmer to describe source code. SPEED-Pascal
bypasses comments so that comments don't have any effect on the code
generation.
A Comment can be placed on every position in the source code.
Comments can start with one of the following character(s):
* { character
* (* characters
* /* characters
Comments must end with one of the following character(s):
* } character (if comment started with {)
* *) characters (if comment started with (*)
* */ characters (if comment started with /*)
That means: You must enclose comments with "{...}", "(*...*)" or "/*...*/".
Between the start and the end markers of a comment any text can be.
SPEED-Pascal/2 doesn't allow nested comments (a comment within a comment).
Examples for vaild comments:
{This is a comment}
/*Another Comment*/
(*Just another...*)
Chapter 2. Structure of SPEED-Pascal/2 Programs
===============================================
Overview
--------
All SPEED-Pascal/2 programs are separately compilable units. Usually a
program consists of a main unit and several libraries that are linked
together to one executable (the EXE file) which can directly be executed
by OS/2.
This section describes the basic structure of a SPEED-Pascal/2 Program.
You will also learn more about using Units (Libraries) with SPEED-Pascal/2.
Basic structure of a SPEED-Pascal/2 Program
-------------------------------------------
Any SPEED-Pascal/2 Program consists of the parts illustrated by the following
graphic:
┌──────────────────────────────────────────────────────────────────┐
│ SPEED-Pascal/2 Program │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ PROGRAM Head; │ │
│ └──────────────────────────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ Label Declarations; │ │
│ │ Type Declarations; │ │
│ │ Constant Definitions; │ │
│ │ Variable Definitions; │ │
│ │ Procedure Declarations; │ │
│ │ Function Declarations; │ │
│ │ Macro Declarations; │ │
│ │ │ │
│ └──────────────────────────────────────────────────────────────┘ │
│ │
│ BEGIN │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Statement(s); │ │
│ │ . │ │
│ │ . │ │
│ │ . │ │
│ │ Statement(s); │ │
│ └─────────────────────────────────────────────────────────┘ │
│ END. │
│ │
└──────────────────────────────────────────────────────────────────┘
The various types of Delarations and Definitions are optional and can
appear in any order.
A Program must start with the reserved word PROGRAM followed by the name
of the Program (which is a user defined unique name) and a semicolon.
The Execution of the Program starts with that statement that follows the
reserved word BEGIN.
Note that this structure is only valid for the Main Executable file.
Units or DLL's must have another structure. This is discussed in the
chapters "Using libraries with SPEED-Pascal" and "Using DLL's with SPEED-
Pascal".
Example for a valid SPEED-Pascal/2 Program:
PROGRAM Test;
BEGIN
WriteLn('My first program !');
END.
If this program is compiled and started it'll display the text "My first
program !" on the screen.
Libraries are like Procedures and Functions a way to structurize your
program and make it more readable to other users.
A Library provides usually several Procedures and Functions that can be
used by other units (Libraries) or programs.
With SPEED-Pascal/2 several Standard Libraries are delivered. IF you want to
use functions frome these units you must tell the compiler where to
find these functions. The compiler is such intelligent that it searches
for a function in every library that you told him to use. Therefore you
only have to import libaries which contain code you plan to use.
For importing functions from a library use the reserved word USES followed
by the name of the library you plan to use. The standard unit SYSTEM is
always imported so that you don't have to import SYSTEM.
For example you wish to use the function "DosVersion" from the unit PMDos.
The resulting program would be the following:
PROGRAM UnitTest;
USES Dos; {This is here to import the Unit}
VAR {Declare a variable v that holds the OS/2 Version numbers}
v:WORD;
BEGIN
v:=DosVersion; {Get the OS/2 Version}
Writeln('OS/2 Version is:',v AND 255,'.',v SHR 8); {Put out version}
END.
For more information about libraries refer to chapter "Using libraries with
SPEED-PASCAL/2".
Using the syntax description
----------------------------
In the following for the description of the Syntax of SPEED-Pascal/2 an
Extended Backus Naur Form (EBNF) is used.
The following Meta Symbols are used in this description:
CHARACTERSTRING : Terminal-Symbols - use without change in your source
code
<Characterstring> : Non-Terminal-Symbols - point to another Non Terminal
Symbol. The construction has to be replaced by
the resulting Terminal-Symbol(s).
| : Alternative - One Element from the construction has to
be choosen.
[] : The construction within these brackets is optional.
{} : Repeat - The construction within those brackets
can be repeated multiple times or can be deleted.
::= : "Is defined as" - Assign a construction to a
Non-Terminal-Symbol.
<empty> : Empty Symbol-Stream - The construction can also be
empty.
.. : Values covered by this range are valid.
f.e.: A..Z,a..z,_ --> all letters and the charater
"_".
"c" : Single character. This character must be used
unchanged in your source code.
Description of the SPEED-Pascal/2 Grammar
-----------------------------------------
In the following a complete description of the Grammar of SPEED-Pascal/2 is
given in EBNF. (see "Using the syntax description")
Syntax:
-------
<Program> ::= <Program-Head> <Block> "."
| <Unit-Head> <Block> "."
<Program-Head> ::= PROGRAM <Identifier> ";"
| PROGRAM <Identifier> "(" INPUT ","
OUTPUT ")" ";"
| LIBRARY <Identifier> ";"
<Unit-Head> ::= UNIT <Identifier> ";"
INTERFACE <Interface-Block>
IMPLEMENTATION
<Interface-Block> ::= <Import-Declaration>
<Label-Declaration>
<Constant-Declaration>
<Type-Definition>
<Variable-Definition>
<Export-Procedure>
<Export-Function>
<DLL-Importdefinition>
| <empty>
<Export-Procedure> ::= PROCEDURE <Identifier> <Paramterlist> ";"
| <empty>
<Export-Function> ::= FUNCTION <Identifier> <Paramterlist> ";"
| <empty>
<Block> ::= <Import-Declaration>
<Label-Declaration>
<Constant-Declaration>
<Type-Definition>
<Variable-Definition>
<Procedure-Declaration>
<Function-Declaration>
<Macro-Declaration>
<Assignment-Block>
<DLL-Importdefinition>
<DLL-Exportdefinition>
<Import-Declaration> ::= USES <identifier> { "," <Identifier> } ";"
| <empty>
<DLL-Importdefinition> ::= IMPORTS <DLLImports> ";" { <DLLImports> ";" }
END ";"
<DLLImports> ::= <DLLProcHead>
| <DLLFuncHead>
<DLLProcHead> ::= PROCEDURE <Identifier> <Paramterlist> <DLLImp>
| <empty>
<DLLFuncHead> ::= FUNCTION <Identifier> <Paramterlist> <DLLImp>
| <empty>
<DLLImp> ::= ":" <Identifier> INDEX <Fixed-Number>
| ";" <Identifier> INDEX <Fixed-Number>
| ":" "'" <Identifier> "'" <Fixed-Number>
| ";" "'" <Identifier> "'" <Fixed-Number>
<DLL-Exportdefinition> ::= EXPORTS <DLLExports> ";" { <DLLExports>
";" } END ";"
<DLLExports> ::= <Identifier>
<Label-Declaration> ::= LABEL <Identifier> { "," <Bezeichner> } ";"
| <empty>
<Constant-Declaration> ::= CONST <Identifier> <Constantblock> ";"
| <empty>
<Constantblock> ::= "=" <Constant>
| ":" <Type> "=" <Constant>
<Type-Definition> ::= TYPE <Identifier> "=" <Type> ";"
| <empty>
<Type> ::= <Identifier>
| "^" <Identifier>
| BYTE
| CHAR
| DOUBLE
| EXTENDED
| WORD
| INTEGER
| LONGINT
| LONGWORD
| REAL
| FILE
| TEXT
| POINTER
| RECORD <Recordlist> END
| ARRAY <Arraylist> OF <Type>
| SET OF <Type>
| STRING
| PSTRING
| STRING [ <Fixed-Number> ]
| OBJECT <Objectlist> END
| PROCEDURE <Parameterlist>
| FUNCTION <Parameterlist> ":" <Type>
| "(" <Constant> { "," <Constant> } ")"
<Recordlist> ::= <Identifierlist> ":" <Type>
| { <Identifierlist> ":" <Type> }
CASE <Identifier> OF <Variant>
<Variant> ::= <Constant> : "( <Variantlist> )" ";"
{ <Constant> ":" "(" <Variantlist> ")" ";" }
<Variantlist> ::= <identifierlist> ":" <Type>
{ ";" <Identifierlist> ":" <Type> }
<Identifierlist> ::= <Identifier> { "," <Identifier> }
<Arraylist> ::= "[" <Fixed-Number> ".." <Fixed-Number>
{ "," <Fixed-Number> ".."
<Fixed-Number> } "]"
<Objectlist> ::= { <Objectvariables> } { <Objectmethods> }
<Objectvariables> ::= <Recordlist>
<Objectmethods> ::= PROCEDURE <Identifier> <Parameterlist> ";"
| PROCEDURE <Identifier> <Parameterlist> ":"
VIRTUAL ";"
| FUNCTION <Identifier> <Parameterlist> ":"
<Type> ";"
| FUNCTION <Identifier> <Parameterlist> ":"
<Type> ":" VIRTUAL ";"
| CONSTRUCTOR <Identifier> <Parameterlist> ";"
| DESTRUCTOR <Identifier> <Parameterlist> ";"
| DESTRUCTOR <Identifier> <Parameterlist> ":"
VIRTUAL ";"
<Parameterlist> ::= "(" <PList> { ";" <PList> } ")"
<PList> ::= <Identifierlist> ":" <Type>
| VAR <Identifierlist> ":" <Type>
<Variable-Definition> ::= <Variablelist> ";" { <Variablelist> ";" }
| <empty>
<Variablelist> ::= VAR <Identifierlist> ":" <Type>
{ ";" <Identifierlist> ":" <Type> }
<Procedure-Declaration>::= PROCEDURE <Identifier> <Proclist>
| PROCEDURE <Identifier> "." <Identifier>
<Proclist>
| CONSTRUCTOR <Identifier> "." <Identifier>
<Proclist>
| DESTRUCTOR <Identifier> "." <Identifier>
<Proclist>
<Proclist> ::= <Proc-Head> ";" <Proc-Block> ";"
<Proc-Head> ::= <Parameterlist> ";" <Proctyp>
| ";" <Proctyp>
<Proctyp> ::= ASM ";"
| CDECL ";"
| FORWARD ";"
| <empty>
<Function-Declaration> ::= FUNCTION <Identifier> <Functionlist>
| PROCEDURE <Identifier> "." <Identifier>
<Functionlist>
<Functionlist> ::= <Function-Head> <Proc-Block> ";"
<Function-Head> ::= <Parameterlist> ":" <Type> ";" <Proctyp>
| ":" <Type> ";" <Proctyp>
<Macro-Declaration ::= MACRO <Identifier> <Macrolist>
| MACRO <Identifier> ":" <Type> ";"
<Macrolist>
<Macrolist> ::= <Statement-Block> ";"
<Proc-Block> ::= <Label-Declaration>
<Constant-Declaration>
<Type-Definition>
<Variable-Definition>
<Statement-Block>
<Statement-Block> ::= BEGIN <Statements> END
<Statements> ::= { <Statement> ";" }
<Statement> ::= <Proc-Call>
| <Assignment>
| <Goto>
| <Case>
| <Repeat>
| <If>
| <With>
| <While>
| <For>
<Proc-Call> ::= <Identifier>
| <Identifier> "(" <Expressionlist> ")"
| <Identifier> "." <Identifier>
| <Identifier> "." <Identifier>
"(" <Expressionlist> ")"
<Expressionlist> ::= <Expression> { "," <Expression> }
<Assignment> ::= <Variable> ":=" <Expression>
<Goto> ::= GOTO <Identifier>
<Case> ::= CASE <Variable> OF <Caselist> END
<Caselist> ::= { <Constant> : <Statement-Block> ";" }
| { <Constant> : <Statement-Block> }
ELSE <Statement-Block> ";"
<Repeat> ::= REPEAT <Anweisungen> UNTIL <Bedingung>
<If> ::= IF <Expression> <Comp> <Expression> DO
<ifexpression>
<ifexpression> ::= <Statement>
| <Statement> ELSE <elseexpression>
| <Statement-Block>
| <Statement-Block> ELSE <elseexpression>
<elseexpression> ::= <Statement>
| <Statement-Block>
<With> ::= WITH <Variable> DO <withexpression>
<withexpression> ::= <Statement>
| <Statement-Block>
<While> ::= WHILE <Expression> <Comp> <Expression> DO
<whileexpression>
<whileexpression> ::= <Statement>
| <Statement-Block>
<For> ::= FOR <Variable> ":=" <Expression> <Direction>
<Expression> DO <forexpression>
<forexpression> ::= <Statement>
| <Statement-Block>
<Direction> ::= TO
| DOWNTO
<Comp> ::= ">"
| "<"
| "="
| ">="
| "<="
| "<>"
<Variable> ::= <Identifier>
| <Variable> ^
| <Variable> . <Variable>
| <Variable> "[" <Expression> { ","
<Expression> } "]"
<Expression> ::= <Variable>
| <Proc-Call>
| <Consant>
| <Expression> <Operator> <Expression>
{ <Operator> <Expression> }
<Operator> ::= "+"
| "-"
| "*"
| "/"
| "!"
| "|"
| "&"
| DIV
| MOD
| AND
| OR
| XOR
| NOT
| SHL
| SHR
<Constant> ::= <Identifier>
| <Fixed-Number>
| "$" A..F|a..f|0..9 {A..F|a..f|0..9}
| <Fixed-Number> "." <Fixed-Number>
| NIL
| TRUE
| FALSE
<Identifier> ::= A..Z|a..z|_ { A..Z|a..z|0..9|_ }
<Fixed-Number> ::= 0..9 { 0..9 }
Chapter 3. Declarations
=======================
Overview
--------
CONST Declaration
-----------------
VAR Declaration
---------------
TYPE Declaration
----------------
LABEL Declaration
-----------------
Chapter 13 Internal details
===========================
VMT and DMT Table layout
------------------------
VMT and DMT can only be used within Objects.
Note: The Dynamic method table can only be used when you use the
Object-PM Libary or from assembler level. There is no other
way to get the adresses of DMT-procedures/functions.
Since that Dynamic methods have only one parameter.
Dynamic methodes MUST match the following form:
PROCEDURE <Name>(VAR Msg:TMessage);VIRTUAL <XXX>;
Where <Name> is the name of the method and <XXX> the
Message ID. The method is (when using Object-PM) called
if the message appears.
The Type TMessage is defined in the unit Objects. If you
want to create your own Object-PM library (WHY ?) this
type name MUST mach or the compiler will tell an error !
The DMT is located in the Codesegment. Since that you
cannot write to the DMT until you've created an Alias
Descriptor !
VMT Offset Description
0 (POINTER) Adress of virtual method list
4 (POINTER) Adress of dynamic method table (DMT)
8 and further Object variables
The virtual method list is an array[1..MaxMethods] of POINTER and consists
of procedure/function addresses that correspondent with
the logical index of the method within the object. (The first procedure/
constructor/destructor or function has index 1).
MaxMethods is the overall count of methods you defined no matter
if virtual or not.
The Method names at assembler level are named as _!<Name>_<XXX> where
<Name> is the name of the object and <XXX> is the logical index of the
method in the object as described below.
The DMT exists for each object no matter if dynamic methods are defined.
DMT Offset Description
0 (LONGWORD) Size of the DMT for this object (without this length)
4 (LONGWORD) Message ID
8 (LONGWORD) VMT Index of the procedure/function that belongs to the
message above and should be called when the message
appears.
12 (LONGWORD) Message ID
16 (LONGWORD) VMT Index of the procedure/function that belongs to the
message above and should be called when the message
appears.
.
.
.
Using the Compiler/Assembler/Resource Compiler as DLL's
-------------------------------------------------------
The SPEED-PASCAL/2 Compiler, Assembler and Resource Compiler are distributed
as DLL's and invoked from the IDE.
IF you want to include PASCAL/2 in your own programs you can use these
DLL's.
When doing so you MUST recognize the copyright terms. You are NOT
allowed to distribute, sell or rent or give away the SPEED-PASCAL/2 Compiler,
Assembler or Resource Compiler with any commercial or private programs
without having contacted the author !
You can free use this DLL functions for private purposes.
Note that all functions must be called with PASCAL calling convention
since SPEED-PASCAL/2 itself was written in SPEED-PASCAL/2.
Structure alignment must be 1 (BYTE).
The following structure must be filled before calling:
TYPE
TParams=Record
Quell:STRING; {File to Compile}
Lib:STRING; {Library directory}
Out:STRING; {Output directory}
Libsrc:STRING; {Library sources (for Build)}
Params:STRING; {Command line parameters}
InMemory:PMemoryList;
End;
Where
* Quell is the full qualified name of the file to compile in upper
chars including path and extension.
* Lib is the search path to the libraries WITHOUT an '\' at the end
* Out is the search path to the output directory WITHOUT an '\' at
he end
* Libsrc is the search path to the library sources WITHOUT an '\' at
the end
* Params holds the parameters as it is from the command line
(only switches and options).
* InMemory allows you to compile files that are in memory and MUST
be set to NIL if this is no memory file !
Note that the file in memory must match a file that would be on disk.
The Type PMemoryList is declared as
TYPE
PMemoryList=^TMemoryList;
TMemoryList=RECORD
Name:String;
Adresse:LONGWORD;
Len:LONGWORD;
Next:PMemoryList;
END;
Where:
* Name is the full qualified name of the file to compile in
upper chars including path and extension.
* Adresse is the virtual 32 Bit address where the text
starts.
* Len is the length of the file in memory
* With the Next parameter you can define multiple files that
are in memory. At the end of the list Next MUST have the
value ZERO.
The following structure is returned after the call:
TYPE
TReturn=Record
ErrorStr:STRING;
ErrorLine:WORD;
ErrorColumn:WORD;
Error:BOOLEAN;
ErrorFile:String;
End;
Where:
* ErrorStr holds the error. This field is only set if error=TRUE.
* ErrorLine holds the line where the error was found.
* ErrorColumn holds the column where the error was found.
* Error is set to TRUE if an error occured.
* Errorfile contains the full qualified file where the error
was found.
Note that the length of a STRING is 257 in SPEED since SPEED appends a #0
char at the end of the string. The first string index (0) must contain
the length of the string. A STRING therefore is declared as an
ARRAY[0..256] OF char.
Invokation of the SPEED-PASCAL/2 Compiler:
PROCEDURE InvokePas(VAR Params:TParams;
VAR Return:TReturn): PASDLL index 1;
Invokation of the Assembler:
PROCEDURE InvokeAsm(VAR Params:TParams;
VAR Return:TReturn): ASMDLL index 1;
Invokation of the Resource Compiler:
PROCEDURE InvokeRes(VAR Params:TParams;
VAR Return:TReturn): RESDLL index 1;