mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-16 00:11:29 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@13642 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
c2c2d22254
192 changed files with 19443 additions and 0 deletions
3
.dist-ignore
Normal file
3
.dist-ignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
New
|
||||
Ignore
|
||||
.snap-ignore
|
340
COPYING
Normal file
340
COPYING
Normal file
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
504
COPYING.LIB
Normal file
504
COPYING.LIB
Normal file
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
138
ChangeLog
Normal file
138
ChangeLog
Normal file
|
@ -0,0 +1,138 @@
|
|||
2002 Apr 20
|
||||
|
||||
* COPYING: updated
|
||||
* STExterns: Removed unused exceptions
|
||||
* STStructure: Changed exception to STInternalIncosistencyException
|
||||
|
||||
2002 Apr 13
|
||||
|
||||
* Modules/GNUmakefile: added option that disables making of appkit support
|
||||
Use make appkit=no.
|
||||
* Separated AppTalk
|
||||
|
||||
2002 Mar 21
|
||||
|
||||
* STEnvironment: removed pools
|
||||
|
||||
2002 Mar 17
|
||||
|
||||
* STEngine: removed executeScript: methods and use only executeSource:
|
||||
engine does not make difference between script and statements anymore
|
||||
* Tools: removed --expressions option
|
||||
* Examples: fixed Smalltalk examples to use new grammar
|
||||
* STLanguage: new method languageNameForFileType:
|
||||
|
||||
2002 Mar 13
|
||||
|
||||
* AppKit module: removed old AppKit constants and renamed MiddleButton
|
||||
events to OtherButton.
|
||||
|
||||
2002 Feb 14
|
||||
|
||||
* added make option 'appkit'. if you set it to 'no' (make appkit=no),
|
||||
no appkit stuff will be compiled.
|
||||
|
||||
2002 Feb 5
|
||||
|
||||
* StepTalk 0.5.0 released
|
||||
|
||||
2002 Feb 5
|
||||
|
||||
* STSelector: new file
|
||||
* NSInvocation+additions: handle SEL type with STSelector
|
||||
* Examples: added selector.st, notification.st, scope.st and pldes.st
|
||||
|
||||
2002 Feb 3
|
||||
|
||||
* Testing: new directory
|
||||
|
||||
2002 Jan 30
|
||||
|
||||
* STEnvironment: Removed unused variables,
|
||||
|
||||
2002 Jan 23
|
||||
|
||||
* NSNumber+additions: moved from Smalltalk, added methods for creation of
|
||||
range, point and size
|
||||
|
||||
2002 Jan 21
|
||||
|
||||
* StepTalk 0.4.1 released
|
||||
|
||||
2002 Jan 21
|
||||
|
||||
* Removed Foundation constants to separate module
|
||||
* stexec: load Foundation module instead of loading all ObjC classes
|
||||
|
||||
2002 Jan 13
|
||||
|
||||
* Guile: new language bundle
|
||||
|
||||
2002 Jan 9
|
||||
|
||||
* StepTalk 0.4.0 released
|
||||
|
||||
2002 Jan 9
|
||||
|
||||
* STFunctions: new function STUserConfigPath
|
||||
* STLanguage: new method languageForFileType:
|
||||
* new tool stupdate_languages to create/update languages configuration file
|
||||
|
||||
2001 Dec 8
|
||||
|
||||
* NSInvocation+addition: return receiver (target) when return type is void
|
||||
|
||||
2001 Nov 19
|
||||
|
||||
* STModule: New method -classNames; returns array of names of exported
|
||||
classes
|
||||
|
||||
2001 Nov 14
|
||||
|
||||
* removed force of use of users home directory for installation
|
||||
* new module AppKit
|
||||
* STEnvironment: new method -addAllClasses to add all Objective-C classes
|
||||
|
||||
2001 Nov 10
|
||||
|
||||
* StepTalk 0.3.0 released
|
||||
|
||||
2001 Nov 10
|
||||
|
||||
* Added scriptable server example.
|
||||
|
||||
2001 Nov 9
|
||||
|
||||
* STExecutor: new options: --list-objects, --list-classes and
|
||||
--list-all-objects
|
||||
* Tools/stalk.m: resurected
|
||||
* Tools/GNUmakefile: uncommented stalk tool
|
||||
* moved initialization of STNil from STUndefinedObject to STEngine
|
||||
|
||||
2001 Nov 6
|
||||
|
||||
* STProtocolInfo: removed
|
||||
* STBehaviourInfo, STClassInfo, STEnvironmentDescription: rewritten
|
||||
* Environment description files changed
|
||||
|
||||
2001 Nov 5
|
||||
|
||||
* Tools/stexec: fixed bug, that caused segfault (reported by
|
||||
Nicola Pero <nicola@brainstorm.co.uk>)
|
||||
* Examples: new directory with Smalltalk script examples
|
||||
* STEnvironment: fixed restricted/full scripting.
|
||||
translateSelector:forReceiver: now raises an exception if selector is not
|
||||
allowed for receiver; standardScriptingEnvironemnt renamed to
|
||||
defaultScriptingEnvironment and calls
|
||||
STEnvironmentDescription defaultEnvironmentDescriptionName
|
||||
* STEnvrionmentDescription: New method +defaultEnvironmentDescriptionName.
|
||||
|
||||
2001 Nov 3
|
||||
|
||||
* Tools: implemented --environment switch to use environment description
|
||||
with name.
|
||||
|
||||
2001 Nov 1
|
||||
|
||||
* New ChangeLog started. Rewritten and redesigned.
|
||||
* Added support for multiple languages. Created Smalltalk language bundle.
|
17
Documentation/ApplicationScripting.txt
Normal file
17
Documentation/ApplicationScripting.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
Application Scripting
|
||||
---------------------
|
||||
|
||||
To make your applications scriptable, you have to make and install AppTalk
|
||||
library.
|
||||
|
||||
|
||||
See documents in AppTalk/Documentation where you may find more information
|
||||
about:
|
||||
|
||||
Installing AppTalk
|
||||
Creating a scriptable application in a few minutes
|
||||
Scripts locations
|
||||
|
||||
You may find AppTalk sources at the same place as StepTalk
|
||||
|
||||
http://steptalk.host.sk
|
15
Documentation/Defaults.txt
Normal file
15
Documentation/Defaults.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
StepTalk Defaults
|
||||
-----------------
|
||||
|
||||
StepTalk uses defaults domain with name 'StepTalk'.
|
||||
|
||||
For example, to set default language name:
|
||||
|
||||
> defaults write StepTalk DefaultLanguageName Smalltalk
|
||||
|
||||
|
||||
Name: DefaultLanguageName
|
||||
Type: String
|
||||
|
||||
Name: DefaultEnvironmentDescriptionName
|
||||
Type: String
|
57
Documentation/Environment.txt
Normal file
57
Documentation/Environment.txt
Normal file
|
@ -0,0 +1,57 @@
|
|||
Scripting environment descriptions
|
||||
----------------------------------
|
||||
|
||||
Property list containing dictionary with keys:
|
||||
|
||||
Name
|
||||
Name of scripting description
|
||||
|
||||
Use
|
||||
Array of scripting descriptions to include.
|
||||
|
||||
Behaviours
|
||||
Dictionary of behaviour descriptions, that can be adopted by a class or
|
||||
another behaviour.
|
||||
|
||||
Classes
|
||||
Dictionary of class descriptions.
|
||||
|
||||
DefaultRestriction
|
||||
|
||||
|
||||
Aliases object name aliases (not impl.)
|
||||
|
||||
|
||||
Behaviours
|
||||
----------
|
||||
Use
|
||||
Adopt behaviour
|
||||
|
||||
SymbolicSelectors
|
||||
Map of symbolic selectors.
|
||||
|
||||
Aliases
|
||||
Method name aliases.
|
||||
|
||||
AllowMethods
|
||||
List of allowed methods.
|
||||
|
||||
DenyMethods
|
||||
List of denied methods.
|
||||
|
||||
|
||||
|
||||
Classes
|
||||
-------
|
||||
(Same items as in Behaviours)
|
||||
|
||||
Super
|
||||
Super class name.
|
||||
|
||||
Restriction
|
||||
Values: DenyAll, AllowAll
|
||||
|
||||
"DenyAll" deny all methods except those in "AllowMethods" list or
|
||||
in "Aliases"
|
||||
"AllowAll" allow all methods except those in "DenyMehods" list.
|
||||
|
28
Documentation/HowTo.txt
Normal file
28
Documentation/HowTo.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
StepTalk HowTo
|
||||
----------------------
|
||||
|
||||
Here are some references where you may find how to use StepTalk:
|
||||
|
||||
How to create scripting environment?
|
||||
|
||||
Tools/stalk.m
|
||||
-createEnvironment
|
||||
|
||||
How to execute code?
|
||||
|
||||
Tools/STExecutor.m
|
||||
-executeScripts
|
||||
-executeScript:withArguments:
|
||||
|
||||
How to create a language bundle?
|
||||
|
||||
Languages/Smalltalk/LanguageEngine.m
|
||||
Languages/Smalltalk/LanguageEngine.h
|
||||
|
||||
Languages/Smalltalk/STBytecodeInterpreter.m
|
||||
- sendSelectorAtIndex:withArgCount:
|
||||
|
||||
|
||||
How to create a scriptable server?
|
||||
|
||||
see Examples/Server
|
21
Documentation/Languages.txt
Normal file
21
Documentation/Languages.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
Languages
|
||||
---------
|
||||
|
||||
How to create a language bundle?
|
||||
|
||||
In directory Languages/Smalltalk/ see files
|
||||
|
||||
SmalltalkEngine.[hm]
|
||||
SmalltalkInfo.plist
|
||||
|
||||
and in STBytecodeInterpreter.m see method - sendSelectorAtIndex:withArgCount:
|
||||
|
||||
|
||||
LanguageInfo.plist
|
||||
------------------
|
||||
STLanguageName
|
||||
Language name that will be used instead of bundle name.
|
||||
|
||||
STEngine;
|
||||
Engine class name. If there is no such class, then princicpial class
|
||||
will be used.
|
7
Documentation/ObjCTypes.txt
Normal file
7
Documentation/ObjCTypes.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
Conversion between objects and Objective-C types
|
||||
------------------------------------------------
|
||||
|
||||
Number types - NSNumber
|
||||
char * - NSString
|
||||
id, class - no conversion
|
||||
structures - STStructure
|
183
Documentation/Old/DESIGN
Normal file
183
Documentation/Old/DESIGN
Normal file
|
@ -0,0 +1,183 @@
|
|||
There was an idea to create general - language independent scripting
|
||||
framework for GNUstep. Here is a sketch of such framework.
|
||||
|
||||
Idea is to have applications, that can execute scripts or just one-line
|
||||
statements in any available scripting language.
|
||||
|
||||
Scripting Environment
|
||||
---------------------
|
||||
|
||||
An application will prepare scripting environment by making some of apps
|
||||
objects available by some name.
|
||||
|
||||
ex.:
|
||||
STEnvironment *env;
|
||||
|
||||
[env addObject:mail withName:@"mail"];
|
||||
[env addObject:[mail subject] withName:@"subject"];
|
||||
[env addObject:[mail receiver] withName:@"receiver"];
|
||||
|
||||
|
||||
|
||||
Environment is something like language context, where script is being
|
||||
executed. There are objects registered by name, so you can use them from your
|
||||
script. Your application can have several environments. For example, one for
|
||||
each document, mail...
|
||||
|
||||
ex. (Example is going to be a mail filter. Let mail filter by a association
|
||||
between mailbox and a expression. Whe expression is true, mail goes to that
|
||||
mailbox.):
|
||||
|
||||
receiver == 'gnustep-dicuss@gnu.org'
|
||||
|
||||
or something like this:
|
||||
|
||||
addressBook emailAddressesForGroupWithName:'firends'
|
||||
contains:receiver
|
||||
|
||||
Also, scripting environment contains method name alias/restriction. For
|
||||
example, I've used method aliases to map Smalltalk bynary selectors to
|
||||
gnustep methods, like when sending selector '@' to NSArray, it is translated
|
||||
to 'objectAtIndex:'. With method restriction, you can deny some methods to a
|
||||
class. This can be used to prevent creating script viruses. Your application
|
||||
just denies methods of some classes not available for scripting. For example,
|
||||
you can deny method for deleting files, allocating some kinds of objects...
|
||||
This can be enabled or disabled, when it is disabled, I call it full
|
||||
scripting - you can send any message to any kind of object. Application can
|
||||
have environment description(s) in a file (example attached) or it can
|
||||
allow/deny by 'hand' using STEnvironments:
|
||||
|
||||
- denySelector:forObjectsOfType:
|
||||
- allowSelector:forObjectsOfType:
|
||||
- denyAllSelectorsForObjectOfType:
|
||||
- allowAllSelectorsForObjectOfType:
|
||||
|
||||
Scripting Engine
|
||||
----------------
|
||||
|
||||
Scripting engine is used for executing scripts.
|
||||
|
||||
ex.:
|
||||
|
||||
STEgnine *engine /* say we already have this */;
|
||||
...
|
||||
|
||||
engine = [STEngine engineForLanguage:@"Smalltalk"];
|
||||
|
||||
[engine executeCode:filter
|
||||
inEnvironment:[activeMail scriptingEnvironment]];
|
||||
...
|
||||
|
||||
|
||||
Engine and Languages
|
||||
--------------------
|
||||
The idea was, as also Lyndon mentioned before, to have "bundled languages".
|
||||
Engine will load appropriate bundle for language, that is actualy needed.
|
||||
|
||||
Application does not have to know anything about scripting languages. It is
|
||||
the matter of user. But, user has to be able to specify the language used for
|
||||
scripting in application. Or...there sould be a language autodetection.
|
||||
|
||||
The interface between Engine and backend (bundled language)
|
||||
|
||||
- executeCode:inEnvironment:
|
||||
|
||||
- understandsCode: /* can be used for language auto-detection when language is
|
||||
nil or @"" or @"auto"... */
|
||||
|
||||
Scripting framework does not care, if the language is compiled, or directly
|
||||
interpreted.
|
||||
|
||||
Language backend will just execute a script and send messages to objects. It
|
||||
can use environment to get the real selector:
|
||||
|
||||
STEnvironment *environment; /* we have this ... */
|
||||
id target; /* ... and also this */
|
||||
NSString *selector;
|
||||
...
|
||||
selector = [environment translateSelector:selector forReceiver:target];
|
||||
|
||||
|
||||
invocation = [NSInvocation invocationWithTarget:target
|
||||
selectorName:selector];
|
||||
|
||||
... /* set arguments */ ...
|
||||
[invocation invoke];
|
||||
|
||||
For larger example see source STBytecodeInterpreter.m in Smalltalk language
|
||||
module, method:
|
||||
- (void)sendSelectorAtIndex:(unsigned)selIndex
|
||||
withArgCount:(unsigned)argCount
|
||||
|
||||
|
||||
In StepTalk there already some additions, that can be used:
|
||||
|
||||
NSInvocation
|
||||
- (void)setArgumentAsObject:(id)anObject atIndex:(int)anIndex
|
||||
- (id)getArgumentAsObjectAtIndex:(int)anIndex
|
||||
- (id)returnValueAsObject
|
||||
|
||||
These two methods are converting between GNUstep objects (NSNumber,
|
||||
NSString,...) and simple C types (int, char *, ...)
|
||||
|
||||
|
||||
Languages and Language Bundles
|
||||
------------------------------
|
||||
|
||||
Language bundles can be stored in
|
||||
|
||||
*_GNUSTEP_ROOT/Library/Scripting/Languages
|
||||
|
||||
It will be good, if there will be some kind of description of that language,
|
||||
language aliases (objc, objective-c, objectivec,...)
|
||||
|
||||
Defaults
|
||||
--------
|
||||
Suggested defaults:
|
||||
|
||||
STFullScripting (bool) - enable full scripting by default for all apps
|
||||
STDefaultsScriptingLanguage - default scripting language
|
||||
|
||||
|
||||
Remote scripting
|
||||
-----------------
|
||||
The idea is to script application/server remotely. You connect to scripted
|
||||
object, where an new scripting environment is created. Script is executed in
|
||||
that environment. Application may customize the environment depending on the
|
||||
caller or may limit number of scripting connections, etc...
|
||||
|
||||
The method should be
|
||||
- remoteScriptingEngine
|
||||
or there should be some authentification of caller.
|
||||
|
||||
Summary
|
||||
-------
|
||||
Application developers:
|
||||
|
||||
STEnvironment interface
|
||||
- addObject:anObject withName:(NSString *)name
|
||||
|
||||
- denySelector:forObjectsOfType:
|
||||
- allowSelector:forObjectsOfType:
|
||||
- denyAllSelectorsForObjectOfType:
|
||||
- allowAllSelectorsForObjectOfType:
|
||||
|
||||
OR
|
||||
|
||||
environment description file(s)
|
||||
|
||||
STEngine interface
|
||||
|
||||
+ engineForLanguageWithName:(NSString *)name
|
||||
|
||||
- executeCode:(NSString *)code
|
||||
inEnvironment:(STScriptingEnvironment *) env
|
||||
|
||||
Language backend developers:
|
||||
|
||||
STEnvironment interface
|
||||
- translateSelector:forReceiver:
|
||||
|
||||
They have to implement theese methods:
|
||||
- executeCode:inEnvironment:
|
||||
- understandsCode:
|
174
Documentation/Smalltalk.txt
Normal file
174
Documentation/Smalltalk.txt
Normal file
|
@ -0,0 +1,174 @@
|
|||
Smalltalk language extensions to NSObjects
|
||||
------------------------------------------
|
||||
|
||||
Contents:
|
||||
1. Source
|
||||
2. Symbolic Selectors
|
||||
3. Iterators and cycles
|
||||
4. Exception handling
|
||||
|
||||
1. Source
|
||||
---------
|
||||
|
||||
Smalltalk script can be list of methods or just list of statements. List of
|
||||
statements is like single method without method name.
|
||||
|
||||
List of methods
|
||||
---------------
|
||||
|
||||
Source begins with '[|' (left square bracket) and is followed by optional list
|
||||
of script variables. Methods are separated by '!' and are encoles by ']' (right
|
||||
square bracket).
|
||||
|
||||
Example without vars:
|
||||
[|
|
||||
main
|
||||
self other.
|
||||
^self
|
||||
!
|
||||
other
|
||||
Transcript showLine:'This is other'.
|
||||
!
|
||||
]
|
||||
|
||||
Example with vars:
|
||||
|
||||
[| :var1 :var2
|
||||
|
||||
main
|
||||
"Your code here...".
|
||||
^self
|
||||
!
|
||||
other
|
||||
"Your code here...".
|
||||
^self
|
||||
!
|
||||
]
|
||||
|
||||
|
||||
Simple script (statements)
|
||||
--------------------------
|
||||
|
||||
Simple script is just list of smalltalk statements. It is like contents of one
|
||||
method.
|
||||
|
||||
|
||||
Why source begins with '[|' and not just '['?
|
||||
---------------------------------------------
|
||||
Look at this example:
|
||||
|
||||
[one two three]
|
||||
|
||||
It has more meanings. It can be:
|
||||
|
||||
- list of methods with one method named 'one'. 'two' is target object and
|
||||
'three' is a message.
|
||||
|
||||
or
|
||||
|
||||
- simple statement with block. 'one' is target object and 'two' and 'three'
|
||||
are messages.
|
||||
|
||||
|
||||
|
||||
2. Symbolic selectors
|
||||
---------------------
|
||||
|
||||
In StepTalk symbolic selectors are mapped to normal selectors.
|
||||
|
||||
Comparison operators (NSObject)
|
||||
-------------------------------
|
||||
|
||||
|
||||
Symb. sel. Real sel.
|
||||
-------------------------------------
|
||||
= isEqual:
|
||||
== isSame:
|
||||
~= notEqual:
|
||||
~~ notSame:
|
||||
< isLessThan:
|
||||
> isGreatherThan:
|
||||
<= isLessOrEqualThan:
|
||||
>= isGreatherOrEqualThan:
|
||||
|
||||
|
||||
Target type Selector Argument Type Real Selector
|
||||
-----------------------------------------------------------------------
|
||||
NSArray @ NSNumber objectAtIndex:
|
||||
NSArray , any arrayByAddingObject:
|
||||
NSArray + any arrayByAddingObject:
|
||||
NSMutableArray += any addObject:
|
||||
NSMutableArray -= any removeObject:
|
||||
|
||||
NSDictionary @ any objectForKey:
|
||||
NSUserDefaults @ any objectForKey:
|
||||
|
||||
NSString , NSString stringByAppendingString:
|
||||
NSString / NSString stringByAppendingPathComponent:
|
||||
NSString @ NSNumber characterAtIndex:
|
||||
NSMutableString += NSString appendString:
|
||||
|
||||
NSSet < NSSet isSubsetOfSet:
|
||||
NSMutableSet += any addObject:
|
||||
NSMutableSet -= any removeObject:
|
||||
|
||||
NSDate - NSDate timeIntervalSinceDate:
|
||||
|
||||
NSNumber +,-,*,/ NSNumber add:,subtract:,multiply:,divide:
|
||||
|
||||
|
||||
|
||||
Special selectors to create objects from two NSNumbers
|
||||
|
||||
Symb.sel. Real sel. Result Methods
|
||||
-------------------------------------------------------
|
||||
<> rangeWith: range location, length
|
||||
@ pointWith: point x, y
|
||||
@@ sizeWith: size width, height
|
||||
|
||||
Examples:
|
||||
str := 'This is string.'.
|
||||
substr := str substringWithRange: (8 <> 3)
|
||||
range := str rangeOfString: 'str'.
|
||||
newRange := ( (range location) <> 6).
|
||||
|
||||
3. Iterator and cycles
|
||||
----------------------
|
||||
Cycles
|
||||
------
|
||||
To create a cycle, you may use whileTrue: or whileFalse: on NSBlock
|
||||
|
||||
conditionBlock whileTrue: toDoBlock.
|
||||
|
||||
To use a sequence of numbers, you may use to:do: or to:step:do: on NSNumber
|
||||
|
||||
min to: max do: block
|
||||
min to: max step: step do: block
|
||||
|
||||
Array iterators
|
||||
---------------
|
||||
|
||||
Following methods will iterate through all objects in receiver.
|
||||
|
||||
Selector Description
|
||||
-------------------------------------------------------------------------------
|
||||
do: Evaluate block for each object in array and return last evaluated
|
||||
expression
|
||||
select: Create new array which will contain those objects from receiver,
|
||||
for which value of block was true
|
||||
reject: Create new array which will contain those objects from receiver,
|
||||
for which value of block was false
|
||||
collect: Create new array from block return values.
|
||||
detect: Return first object for which block evaluation result is true.
|
||||
Othervise return nil.
|
||||
|
||||
|
||||
4. Exception handling
|
||||
---------------------
|
||||
|
||||
If you want to handle an exception, you may do so by using blocks. You send
|
||||
handler: message to guarded block.
|
||||
|
||||
guardedBlock handler: handlerBlock.
|
||||
|
||||
If exception occures in guarded block, then handler block is evaluated.
|
45
Examples/AppKit/listFonts.st
Normal file
45
Examples/AppKit/listFonts.st
Normal file
|
@ -0,0 +1,45 @@
|
|||
" listFonts.st
|
||||
|
||||
Example that will create a 'rtf file containing smaples of all available
|
||||
fonts.
|
||||
|
||||
"
|
||||
|
||||
[| :text
|
||||
|
||||
main
|
||||
|
||||
| fontManager |
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
text := NSTextView alloc initWithFrame:NSNullRect.
|
||||
text setRichText:YES.
|
||||
|
||||
fontManager := NSFontManager sharedFontManager.
|
||||
|
||||
(fontManager availableFontFamilies)
|
||||
do: [ :font |
|
||||
self addFontSample:font
|
||||
].
|
||||
|
||||
text writeRTFDToFile:'Fonts.rtf' atomically:YES.
|
||||
|
||||
^nil
|
||||
!
|
||||
|
||||
addFontSample:fontName
|
||||
|
||||
| attr |
|
||||
|
||||
attr := NSMutableDictionary dictionary.
|
||||
attr setObject:(NSFont fontWithName:fontName size:0)
|
||||
forKey:NSFontAttributeName.
|
||||
|
||||
text setTypingAttributes:attr.
|
||||
text insertText:(fontName,'\n').
|
||||
|
||||
^self
|
||||
|
||||
|
||||
]
|
7
Examples/AppKit/openPanel.st
Normal file
7
Examples/AppKit/openPanel.st
Normal file
|
@ -0,0 +1,7 @@
|
|||
Environment loadModule:'AppKit'.
|
||||
|
||||
panel := NSOpenPanel openPanel.
|
||||
|
||||
runResult := panel runModal.
|
||||
|
||||
Transcript showLine: (panel filename).
|
12
Examples/AppKit/panel.st
Normal file
12
Examples/AppKit/panel.st
Normal file
|
@ -0,0 +1,12 @@
|
|||
| app |
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
app := NSApplication sharedApplication.
|
||||
|
||||
app runAlertPanelWithTitle: 'Test'
|
||||
message: 'Alert panel test'
|
||||
defaultButton: 'OK'
|
||||
alternateButton: nil
|
||||
otherButton: nil.
|
||||
|
8
Examples/AppKit/pb.st
Normal file
8
Examples/AppKit/pb.st
Normal file
|
@ -0,0 +1,8 @@
|
|||
" Print available Pasteboard types "
|
||||
| pb |
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
pb := NSPasteboard generalPasteboard.
|
||||
|
||||
Transcript showLine: (pb types).
|
11
Examples/AppKit/printers.st
Normal file
11
Examples/AppKit/printers.st
Normal file
|
@ -0,0 +1,11 @@
|
|||
"List all available printers"
|
||||
|
||||
| printers |
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
printers := NSPrinter printerTypes.
|
||||
printers do:
|
||||
[ :printer |
|
||||
Transcript showLine: printer.
|
||||
]
|
29
Examples/AppKit/rtf2text.st
Normal file
29
Examples/AppKit/rtf2text.st
Normal file
|
@ -0,0 +1,29 @@
|
|||
"
|
||||
rtf2text.st
|
||||
|
||||
Convert RTF document to plain text.
|
||||
|
||||
ussage: stexec rtf2text infile outfile
|
||||
|
||||
"
|
||||
|
||||
| infile outfile rtfString |
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
((Args count) < 2)
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'rtf2text: Please specify input and output filename'.
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
infile := Args @ 0.
|
||||
outfile := Args @ 1.
|
||||
|
||||
rtfString := (NSAttributedString alloc)
|
||||
initWithPath:infile documentAttributes:nil.
|
||||
|
||||
(rtfString string) writeToFile:outfile atomically:YES.
|
||||
|
||||
]
|
22
Examples/AppKit/text.st
Normal file
22
Examples/AppKit/text.st
Normal file
|
@ -0,0 +1,22 @@
|
|||
"NSText test"
|
||||
|
||||
Environment loadModule:'AppKit'.
|
||||
|
||||
tattr := NSMutableDictionary dictionary.
|
||||
tattr setObject:(NSFont fontWithName:'Times' size:10)
|
||||
forKey:NSFontAttributeName.
|
||||
|
||||
hattr := NSMutableDictionary dictionary.
|
||||
hattr setObject:(NSFont fontWithName:'Helvetica' size:10)
|
||||
forKey:NSFontAttributeName.
|
||||
|
||||
text := NSTextView alloc initWithFrame:NSNullRect.
|
||||
text setRichText:YES.
|
||||
|
||||
text setTypingAttributes:tattr.
|
||||
text insertText:'This is Times\n'.
|
||||
|
||||
text setTypingAttributes:hattr.
|
||||
text insertText:'This is Helvetica\n'.
|
||||
|
||||
text writeRTFDToFile:'Test.rtf' atomically:YES.
|
69
Examples/ReadMe.txt
Normal file
69
Examples/ReadMe.txt
Normal file
|
@ -0,0 +1,69 @@
|
|||
Smalltalk examples
|
||||
------------------
|
||||
|
||||
Smalltalk examples are included in Smalltalk directory.
|
||||
|
||||
|
||||
math.st
|
||||
Simple example.
|
||||
|
||||
> stexec math.st
|
||||
|
||||
|
||||
hello.st
|
||||
Example to show block closures, symbolic selectors and ussage of arguments.
|
||||
|
||||
> stexec hello.st
|
||||
> stexec hello.st World
|
||||
|
||||
|
||||
createFile.st
|
||||
|
||||
Try to create a file. Example to show how the restricted scriptiong works.
|
||||
|
||||
This will work fine:
|
||||
> stexec createFile.st
|
||||
|
||||
This would not:
|
||||
> stexec --environment Safe createFile.st
|
||||
|
||||
|
||||
exception.st
|
||||
|
||||
Same as createFile.st but handles the exception.
|
||||
|
||||
This will work fine:
|
||||
> stexec exception.st
|
||||
|
||||
This will end with handled exception:
|
||||
> stexec --environment Safe exception.st
|
||||
|
||||
listDir.st
|
||||
|
||||
List content of current directory.
|
||||
|
||||
> stexec listDir.st
|
||||
|
||||
plparse.st, pldes.st
|
||||
|
||||
GNUstep tools written in smalltalk
|
||||
|
||||
> stexec plparse.st file1 file2 ...
|
||||
|
||||
|
||||
|
||||
Scriptable server example
|
||||
-------------------------
|
||||
|
||||
To compile type
|
||||
|
||||
> make
|
||||
|
||||
Then run server
|
||||
|
||||
> opentool Server
|
||||
|
||||
Then from same directory, but in another terminal try
|
||||
|
||||
> stalk Server talkToServer.st
|
||||
> stalk Server talkToServer.st "Hi there!"
|
35
Examples/Server/GNUmakefile
Normal file
35
Examples/Server/GNUmakefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# StepTalk examples
|
||||
#
|
||||
# Copyright (C) 2000 Stefan Urbanek
|
||||
#
|
||||
# This file is part of the StepTalk.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
#
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
TOOL_NAME = Server
|
||||
|
||||
Server_OBJC_FILES = Server.m
|
||||
|
||||
ADDITIONAL_TOOL_LIBS = -lStepTalk
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/tool.make
|
||||
-include Makefile.postamble
|
65
Examples/Server/Server.m
Normal file
65
Examples/Server/Server.m
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
Server.m
|
||||
|
||||
StepTalk scriptable server example
|
||||
*/
|
||||
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSConnection.h>
|
||||
#import <Foundation/NSHost.h>
|
||||
#import <Foundation/NSRunLoop.h>
|
||||
|
||||
#import <StepTalk/StepTalk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@interface Server:NSObject
|
||||
- say:(NSString *)string;
|
||||
@end
|
||||
|
||||
@implementation Server
|
||||
- (STEnvironment *)scriptingEnvironment
|
||||
{
|
||||
/* here we should add some objects or class references ... */
|
||||
|
||||
return [STEnvironment defaultScriptingEnvironment];
|
||||
}
|
||||
- (NSDate *)date
|
||||
{
|
||||
return [NSDate date];
|
||||
}
|
||||
- say:(NSString *)string
|
||||
{
|
||||
printf("%s\n",[string cString]);
|
||||
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
NSConnection *connection;
|
||||
Server *server = [Server new];
|
||||
|
||||
pool = [NSAutoreleasePool new];
|
||||
|
||||
connection = [NSConnection newRegisteringAtName:@"Server"
|
||||
withRootObject:server];
|
||||
|
||||
if (!connection)
|
||||
{
|
||||
NSLog(@"Unable to register server");
|
||||
[pool release];
|
||||
return 1;
|
||||
}
|
||||
|
||||
NSLog(@"Server started");
|
||||
|
||||
[[NSRunLoop currentRunLoop] run];
|
||||
|
||||
RELEASE(connection);
|
||||
RELEASE(pool);
|
||||
|
||||
return 0;
|
||||
}
|
20
Examples/Server/talkToServer.st
Normal file
20
Examples/Server/talkToServer.st
Normal file
|
@ -0,0 +1,20 @@
|
|||
" talkToServer.stalk
|
||||
|
||||
Server script example
|
||||
|
||||
Ussage:
|
||||
stalk Server talkToServer.st [message]
|
||||
"
|
||||
| message |
|
||||
|
||||
((Args count) < 1 )
|
||||
ifTrue:
|
||||
[
|
||||
message := 'Hello!'. ^0
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
message := Args objectAtIndex: 0. ^0
|
||||
].
|
||||
|
||||
Server say:message
|
17
Examples/Smalltalk/createFile.st
Normal file
17
Examples/Smalltalk/createFile.st
Normal file
|
@ -0,0 +1,17 @@
|
|||
| fileManager fileName data |
|
||||
|
||||
fileManager := NSFileManager defaultManager.
|
||||
|
||||
fileName := '/tmp/TestFile.text'.
|
||||
|
||||
('This is some file' writeToFile:fileName atomically:NO)
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'File was succesfully created.'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
Transcript showLine:'File was not created.'
|
||||
]
|
||||
|
||||
|
29
Examples/Smalltalk/exception.st
Normal file
29
Examples/Smalltalk/exception.st
Normal file
|
@ -0,0 +1,29 @@
|
|||
| fileName flag |
|
||||
|
||||
fileName := '/tmp/TestFile.text'.
|
||||
|
||||
flag := NO.
|
||||
|
||||
[
|
||||
('This is some file' writeToFile:fileName atomically:NO)
|
||||
ifTrue:
|
||||
[ Transcript showLine:'File was succesfully created.']
|
||||
ifFalse:
|
||||
[ Transcript showLine:'File was not created.']
|
||||
]
|
||||
handler:
|
||||
[ :exception |
|
||||
Transcript showLine:('Handled exception: ',(exception name)).
|
||||
Transcript showLine:('Reason : ',(exception reason)).
|
||||
flag := YES
|
||||
].
|
||||
|
||||
flag ifTrue:
|
||||
[
|
||||
Transcript showLine:'Finished with exception'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
Transcript showLine:'Finished succesfully'
|
||||
]
|
||||
|
16
Examples/Smalltalk/extern.st
Normal file
16
Examples/Smalltalk/extern.st
Normal file
|
@ -0,0 +1,16 @@
|
|||
| foo |
|
||||
|
||||
|
||||
"foo is local variable"
|
||||
|
||||
foo := 'Foo'.
|
||||
|
||||
Transcript showLine:( 'This is foo : ', foo ).
|
||||
|
||||
|
||||
" bar is created in environment as extern variable "
|
||||
|
||||
bar := 'Bar'.
|
||||
|
||||
Transcript showLine:( 'And this is bar: ', bar ).
|
||||
|
19
Examples/Smalltalk/hello.st
Normal file
19
Examples/Smalltalk/hello.st
Normal file
|
@ -0,0 +1,19 @@
|
|||
" hello.st
|
||||
|
||||
Ussage:
|
||||
stexec hello.st name
|
||||
"
|
||||
|
||||
((Args count) < 1 )
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'Hello ... who?'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
" See ..../Library/StepTalk/Environments/Foundation-operators.stenv
|
||||
or Source/Environments/Foundation-operators.stenv
|
||||
"
|
||||
|
||||
Transcript showLine: ('Hello ', (Args @ 0), '!').
|
||||
]
|
26
Examples/Smalltalk/listDir.st
Normal file
26
Examples/Smalltalk/listDir.st
Normal file
|
@ -0,0 +1,26 @@
|
|||
| fileManager path files dict |
|
||||
|
||||
fileManager := NSFileManager defaultManager.
|
||||
|
||||
path := fileManager currentDirectoryPath.
|
||||
|
||||
Transcript showLine:( 'Listing of directory: ', path ).
|
||||
|
||||
files := fileManager directoryContentsAtPath:path.
|
||||
|
||||
files do:
|
||||
[ :file |
|
||||
|
||||
dict := fileManager fileAttributesAtPath: (path / file)
|
||||
traverseLink:NO.
|
||||
Transcript showLine:file.
|
||||
|
||||
Transcript showLine: (' Type: ', (dict @ NSFileType)).
|
||||
Transcript showLine: (' Size: ', ((dict @ NSFileSize) stringValue)).
|
||||
Transcript showLine: (' Date: ', ((dict @ NSFileModificationDate)
|
||||
description)).
|
||||
|
||||
Transcript showLine:''
|
||||
]
|
||||
|
||||
|
5
Examples/Smalltalk/math.st
Normal file
5
Examples/Smalltalk/math.st
Normal file
|
@ -0,0 +1,5 @@
|
|||
" Simple example "
|
||||
|
||||
Transcript show:'1 + 1 = '.
|
||||
Transcript showLine: (1 + 1)
|
||||
|
24
Examples/Smalltalk/notification.st
Normal file
24
Examples/Smalltalk/notification.st
Normal file
|
@ -0,0 +1,24 @@
|
|||
" Notification example "
|
||||
[|
|
||||
|
||||
main
|
||||
| nc |
|
||||
|
||||
nc := NSNotificationCenter defaultCenter.
|
||||
|
||||
Transcript showLine:'Registering for notification'.
|
||||
nc addObserver:self selector:#notification: name:'Notification' object:nil.
|
||||
|
||||
Transcript showLine:'Posting notification'.
|
||||
nc postNotificationName:'Notification' object:nil.
|
||||
|
||||
^self
|
||||
!
|
||||
|
||||
notification:notif
|
||||
|
||||
Transcript showLine:'Notification received'.
|
||||
|
||||
^self
|
||||
|
||||
]
|
58
Examples/Smalltalk/pldes.st
Normal file
58
Examples/Smalltalk/pldes.st
Normal file
|
@ -0,0 +1,58 @@
|
|||
"
|
||||
pldes.st
|
||||
|
||||
GNUstep plpdes tool rewriten as Smalltalk script for StepTalk
|
||||
|
||||
Ussage:
|
||||
stexec pldes.st file1 [file2 ...]
|
||||
|
||||
|
||||
"
|
||||
[| :locale
|
||||
|
||||
main
|
||||
locale := (NSUserDefaults standardUserDefaults) dictionaryRepresentation.
|
||||
|
||||
((Args count) < 1 )
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'No file names given to deserialize.'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
Args do:
|
||||
[ :file |
|
||||
[self deserializeFile:file]
|
||||
handler:
|
||||
[ :exception |
|
||||
Transcript showLine:'Loading \'', file, '\' - ', (exception reason).
|
||||
]
|
||||
]
|
||||
].
|
||||
|
||||
^self
|
||||
!
|
||||
|
||||
deserializeFile:file
|
||||
| myData myString result out |
|
||||
|
||||
myData := NSData dataWithContentsOfFile: file.
|
||||
result := NSDeserializer deserializePropertyListFromData: myData
|
||||
mutableContainers: NO.
|
||||
|
||||
(result isNil)
|
||||
ifTrue: [
|
||||
Transcript showLine:'Loading \'',file, '\' - nil property list'.
|
||||
]
|
||||
ifFalse: [
|
||||
|
||||
myString := result descriptionWithLocale: locale indent: 0.
|
||||
myData := myString dataUsingEncoding: NSASCIIStringEncoding.
|
||||
|
||||
out := NSFileHandle fileHandleWithStandardOutput.
|
||||
out writeData: myData;
|
||||
synchronizeFile.
|
||||
].
|
||||
|
||||
^self
|
||||
]
|
79
Examples/Smalltalk/plparse.st
Normal file
79
Examples/Smalltalk/plparse.st
Normal file
|
@ -0,0 +1,79 @@
|
|||
"
|
||||
plparse.st
|
||||
|
||||
GNUstep plparse tool rewriten as Smalltalk script for StepTalk
|
||||
|
||||
Ussage:
|
||||
stexec plparse.st file1 [file2 ...]
|
||||
|
||||
|
||||
"
|
||||
[|
|
||||
|
||||
main
|
||||
|
||||
| string result |
|
||||
|
||||
((Args count) < 1 )
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'No file names given to parse.'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
Args do:
|
||||
[
|
||||
:file | self parseFile:file
|
||||
]
|
||||
].
|
||||
|
||||
^self
|
||||
!
|
||||
|
||||
parseFile: file
|
||||
|
||||
Transcript show: ('Parsing ', file, ' - ').
|
||||
|
||||
[
|
||||
|
||||
string := NSString stringWithContentsOfFile:file.
|
||||
result := string propertyList.
|
||||
|
||||
(result isNil)
|
||||
ifTrue:
|
||||
[
|
||||
Transcript showLine:'nil property list'
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
(result isKindOfClass: (NSDictionary class))
|
||||
|
||||
ifTrue: [ Transcript showLine:'a dictionary']
|
||||
ifFalse:
|
||||
[
|
||||
(result isKindOfClass: (NSArray class))
|
||||
ifTrue: [ Transcript showLine:'an array']
|
||||
ifFalse:
|
||||
[
|
||||
(result isKindOfClass: (NSData class))
|
||||
ifTrue: [ Transcript showLine:'a data']
|
||||
ifFalse:
|
||||
[
|
||||
(result isKindOfClass: (NSString class))
|
||||
ifTrue: [ Transcript showLine:'a string']
|
||||
ifFalse:
|
||||
[
|
||||
Transcript showLine: ('unexpected class - ',
|
||||
result class description )
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
handler:
|
||||
[
|
||||
:localException |
|
||||
Transcript showLine: (localException reason)
|
||||
].
|
||||
]
|
27
Examples/Smalltalk/range.st
Normal file
27
Examples/Smalltalk/range.st
Normal file
|
@ -0,0 +1,27 @@
|
|||
" Range example "
|
||||
|str substr range|
|
||||
|
||||
str := 'I like apples and plums.'.
|
||||
|
||||
Transcript showLine: ('String is : \'', str, '\'').
|
||||
|
||||
substr := str substringWithRange: (7 <> 5).
|
||||
|
||||
Transcript showLine: ('Substring at location 7 with length 5 is \'',
|
||||
substr, '\'').
|
||||
|
||||
range := str rangeOfString: 'tomato'.
|
||||
|
||||
((range location) = NSNotFound)
|
||||
ifTrue:
|
||||
[ Transcript showLine: 'Tomato not found' .].
|
||||
|
||||
range := str rangeOfString: 'plum'.
|
||||
|
||||
Transcript showLine: ('Location of \'plum\' is ', ((range location) stringValue),
|
||||
' and length is ', ((range length) stringValue)).
|
||||
|
||||
range := ( (range location) <> 5).
|
||||
|
||||
Transcript showLine: ('Substring with modified range \'',
|
||||
(str substringWithRange:range), '\'').
|
63
Examples/Smalltalk/scope.st
Normal file
63
Examples/Smalltalk/scope.st
Normal file
|
@ -0,0 +1,63 @@
|
|||
" Variable scope example
|
||||
|
||||
try to run:
|
||||
|
||||
> stexec scope.st , scope.st
|
||||
|
||||
"
|
||||
|
||||
[| :global
|
||||
|
||||
main
|
||||
| local |
|
||||
|
||||
Transcript showLine: ':: Start'.
|
||||
|
||||
(extern isNil) ifTrue:
|
||||
[
|
||||
Transcript showLine: 'Script was run for first time. Setting extern.'.
|
||||
extern := 100.
|
||||
]
|
||||
ifFalse:
|
||||
[
|
||||
Transcript showLine: 'Extern: ', (extern stringValue).
|
||||
].
|
||||
|
||||
local := 10.
|
||||
Transcript showLine: 'Local: ', (local stringValue).
|
||||
|
||||
self setLocal:20.
|
||||
Transcript showLine: 'Local after call: ', (local stringValue),
|
||||
' (has to be 10 not 20)'.
|
||||
|
||||
global := 10.
|
||||
Transcript showLine: 'Global: ', (global stringValue).
|
||||
|
||||
self setGlobal:20.
|
||||
Transcript showLine: 'Global after call 1: ', (global stringValue),
|
||||
' (has to be 20 not 10)'.
|
||||
|
||||
self testGlobal.
|
||||
Transcript showLine: 'Global after call 2: ', (global stringValue),
|
||||
' (has to be 20 not 0)'.
|
||||
|
||||
^nil
|
||||
!
|
||||
|
||||
setLocal:val
|
||||
| local |
|
||||
local := val.
|
||||
^self
|
||||
!
|
||||
|
||||
setGlobal:val
|
||||
global := val.
|
||||
^self
|
||||
!
|
||||
|
||||
testGlobal
|
||||
| global |
|
||||
global := 0.
|
||||
^self
|
||||
|
||||
]
|
27
Examples/Smalltalk/selector.st
Normal file
27
Examples/Smalltalk/selector.st
Normal file
|
@ -0,0 +1,27 @@
|
|||
" Selector example "
|
||||
|
||||
[|
|
||||
|
||||
main
|
||||
self performSelector:#hello.
|
||||
|
||||
^nil
|
||||
!
|
||||
|
||||
hello
|
||||
| b |
|
||||
Transcript showLine:'Hello!'.
|
||||
^self
|
||||
!
|
||||
hello2
|
||||
Transcript showLine:'Hello!'.
|
||||
^self
|
||||
|
||||
!
|
||||
|
||||
hello3
|
||||
|a|
|
||||
Transcript showLine:'Hello!'.
|
||||
^self
|
||||
|
||||
]
|
43
GNUmakefile
Normal file
43
GNUmakefile
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# Main Makefile for the StepTalk
|
||||
#
|
||||
# Copyright (C) 2000 Stefan Urbanek
|
||||
#
|
||||
# Written by: Stefan Urbanek <urbane@decef.elf.stuba.sk>
|
||||
#
|
||||
# This file is part of the StepTalk
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
#
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
include Version
|
||||
|
||||
PACKAGE_NAME = StepTalk
|
||||
|
||||
SUBPROJECTS = \
|
||||
Source \
|
||||
Languages \
|
||||
Modules \
|
||||
Tools
|
||||
|
||||
|
||||
-include GNUMakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
include $(GNUSTEP_MAKEFILES)/Master/source-distribution.make
|
||||
-include GNUMakefile.postamble
|
||||
|
66
GNUmakefile.postamble
Normal file
66
GNUmakefile.postamble
Normal file
|
@ -0,0 +1,66 @@
|
|||
#
|
||||
# GNUmakefile.postamble
|
||||
#
|
||||
# Copyright (C) 2000 Stefan Urbanek
|
||||
#
|
||||
# This file is part of the StepTalk
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Project specific makefile rules
|
||||
#
|
||||
# Uncomment the targets you want.
|
||||
# The double colons (::) are important, do not make them single colons
|
||||
# otherwise the normal makefile rules will not be performed.
|
||||
#
|
||||
|
||||
# Things to do before compiling
|
||||
before-all::
|
||||
ln -sf Source/Headers .
|
||||
|
||||
# Things to do after compiling
|
||||
# after-all::
|
||||
|
||||
# Things to do before installing
|
||||
# before-install::
|
||||
|
||||
# Things to do after installing
|
||||
# after-install::
|
||||
|
||||
# Things to do before uninstalling
|
||||
# before-uninstall::
|
||||
|
||||
# Things to do after uninstalling
|
||||
# after-uninstall::
|
||||
|
||||
# Things to do before cleaning
|
||||
# before-clean::
|
||||
|
||||
# Things to do after cleaning
|
||||
# after-clean::
|
||||
|
||||
# Things to do before distcleaning
|
||||
# before-distclean::
|
||||
|
||||
# Things to do after distcleaning
|
||||
# after-distclean::
|
||||
|
||||
# Things to do before checking
|
||||
# before-check::
|
||||
|
||||
# Things to do after checking
|
||||
# after-check::
|
||||
|
38
Languages/GNUmakefile
Normal file
38
Languages/GNUmakefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# Main Makefile for the StepTalk
|
||||
#
|
||||
# Copyright (C) 2000 Stefan Urbanek
|
||||
#
|
||||
# Written by: Stefan Urbanek <urbane@decef.elf.stuba.sk>
|
||||
#
|
||||
# This file is part of the StepTalk
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
#
|
||||
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
SUBPROJECTS = \
|
||||
Smalltalk \
|
||||
# Guile
|
||||
|
||||
-include GNUMakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
-include GNUMakefile.postamble
|
||||
|
46
Languages/Guile/GNUmakefile
Normal file
46
Languages/Guile/GNUmakefile
Normal file
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Guile language bundle
|
||||
#
|
||||
# Copyright (C) 2000,2001 Stefan Urbanek
|
||||
#
|
||||
# This file is part of the StepTalk.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
#
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME = Guile
|
||||
BUNDLE_EXTENSION := .stlanguage
|
||||
BUNDLE_INSTALL_DIR:=$(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk/Languages
|
||||
|
||||
Guile_OBJC_FILES = \
|
||||
GuileEngine.m
|
||||
|
||||
Guile_PRINCIPAL_CLASS = GuileEngine
|
||||
|
||||
ADDITIONAL_INCLUDE_DIRS += -I../../Source/Headers
|
||||
ADDITIONAL_LIBRARIES += -I../../Source/Headers
|
||||
Guile_BUNDLE_LIBS += -lgstep_guile -lScriptKit $(GUILE_LIBS)
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
-include GNUMakefile.postamble
|
||||
|
||||
STGrammar.m: STGrammar.y
|
||||
$(YACC) -d -pSTC -o$@ $<
|
||||
|
32
Languages/Guile/GuileEngine.h
Normal file
32
Languages/Guile/GuileEngine.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
GuileEngine
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2002 Jan 13
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <StepTalk/STEngine.h>
|
||||
|
||||
@interface GuileEngine:STEngine
|
||||
{
|
||||
}
|
||||
@end
|
90
Languages/Guile/GuileEngine.m
Normal file
90
Languages/Guile/GuileEngine.m
Normal file
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
GuileEngine
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2002 Jan 13
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "GuileEngine.h"
|
||||
|
||||
#import <ScriptKit/Guile.h>
|
||||
#import <StepTalk/StepTalk.h>
|
||||
|
||||
#import <Foundation/NSDebug.h>
|
||||
|
||||
@class NSEnumerator;
|
||||
|
||||
int fake_guile_main(int argc, char **argv)
|
||||
{
|
||||
NSString *sourceCode = (NSString *)argv[1];
|
||||
STEnvironment *env = (STEnvironment *)argv[2];
|
||||
GuileInterpreter *interp;
|
||||
GuileScript *script;
|
||||
GuileSCM *result;
|
||||
NSEnumerator *e;
|
||||
id *obj;
|
||||
|
||||
gstep_init();
|
||||
// gstep_link_base();
|
||||
|
||||
[GuileInterpreter initializeInterpreter];
|
||||
|
||||
interp = AUTORELEASE([[GuileInterpreter alloc] init]);
|
||||
script = AUTORELEASE([[GuileScript alloc] init]);
|
||||
|
||||
e = [[[env defaultObjectPool] allKeys] objectEnumerator];
|
||||
|
||||
/* FIXME: If we do not remove these, we get an exception */
|
||||
[env removeObjectWithName:@"NSProxy"];
|
||||
[env removeObjectWithName:@"NSDistantObject"];
|
||||
[env addObject:env withName:@"Env"];
|
||||
[script setUserDictionary:[env defaultObjectPool]];
|
||||
[script setDelegate:sourceCode];
|
||||
result = [interp executeScript:script];
|
||||
|
||||
/* FIXME: ignore result */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@implementation GuileEngine
|
||||
- (BOOL)understandsCode:(NSString *)code
|
||||
{
|
||||
NSLog(@"Do not know how to chceck if code is Guile.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) executeCode:(NSString *)sourceCode
|
||||
inEnvironment:(STEnvironment *)env
|
||||
{
|
||||
char *args[3];
|
||||
|
||||
args[0] = "dummy";
|
||||
args[1] = (char *)sourceCode;
|
||||
args[2] = (char *)env;
|
||||
|
||||
/* FIXME: ugly trick */
|
||||
gh_enter(3, args, fake_guile_main);
|
||||
}
|
||||
@end
|
||||
|
3
Languages/Guile/GuileInfo.plist
Normal file
3
Languages/Guile/GuileInfo.plist
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
STFileTypes = ( "scm" );
|
||||
}
|
2
Languages/Guile/Tests/hello.scm
Normal file
2
Languages/Guile/Tests/hello.scm
Normal file
|
@ -0,0 +1,2 @@
|
|||
([] Transcript show: ($$ "Hello "))
|
||||
([] Transcript showLine: ([] Args objectAtIndex: 0))
|
1
Languages/Guile/Tests/transcript.scm
Normal file
1
Languages/Guile/Tests/transcript.scm
Normal file
|
@ -0,0 +1 @@
|
|||
([] Transcript showLine: ($$ "Hello from Transcript!"))
|
49
Languages/Smalltalk/ChangeLog
Normal file
49
Languages/Smalltalk/ChangeLog
Normal file
|
@ -0,0 +1,49 @@
|
|||
2002 Mar 17
|
||||
|
||||
* STCompiler, STGrammar: changed grammar to be able to have "methods" or
|
||||
"just statements" in source
|
||||
|
||||
2002 Feb 14
|
||||
|
||||
* STSourceReader: Retain character sets
|
||||
|
||||
2002 Feb 5
|
||||
|
||||
* STSelector+additions.[hm]: new files
|
||||
* STCompiler: use STSelector class for symbol literals
|
||||
|
||||
2002 Feb 3
|
||||
|
||||
* STScriptObject: handle special method 'exit'
|
||||
* STBytecodeInterpreter: added code to halt the interpreter and return from
|
||||
all contexts
|
||||
|
||||
2002 Jan 31
|
||||
|
||||
* STBlock: small speed improvements
|
||||
* STBlockContext: removed evaluateWithArguments:count:, and moved code
|
||||
into STBLock
|
||||
|
||||
2002 Jan 23
|
||||
|
||||
* NSNumber+additions: moved arithmetic code to the library
|
||||
|
||||
2002 Jan 22
|
||||
|
||||
* STCompiler: create one more duplicate of stack top when assigning to a
|
||||
variable.
|
||||
|
||||
2002 Jan 9
|
||||
|
||||
* SmalltalkEngine: implemented executeScript:inEnvironment:
|
||||
|
||||
2001 Dec 8
|
||||
|
||||
* Fixed temporary variable compilation
|
||||
* Added special handling of nil, YES and NO constants; added corresponding
|
||||
bytecodes
|
||||
|
||||
2001 Dec 8
|
||||
|
||||
* CahgeLog started
|
||||
|
15
Languages/Smalltalk/Externs.h
Normal file
15
Languages/Smalltalk/Externs.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Externs
|
||||
Misc. variables
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
extern NSString *STCompilerSyntaxException;
|
||||
extern NSString *STCompilerGenericException;
|
||||
|
||||
extern NSString *STInterpreterGenericException;
|
15
Languages/Smalltalk/Externs.m
Normal file
15
Languages/Smalltalk/Externs.m
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
Externs.m
|
||||
Misc. variables
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
NSString *STCompilerSyntaxException = @"STCompilerSyntaxException";
|
||||
NSString *STCompilerGenericException = @"STCompilerGenericException";
|
||||
|
||||
NSString *STInterpreterGenericException = @"STInterpreterGenericException";
|
67
Languages/Smalltalk/GNUmakefile
Normal file
67
Languages/Smalltalk/GNUmakefile
Normal file
|
@ -0,0 +1,67 @@
|
|||
#
|
||||
# Smalltalk language bundle
|
||||
#
|
||||
# Copyright (C) 2000 Stefan Urbanek
|
||||
#
|
||||
# This file is part of the StepTalk.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
#
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
BUNDLE_NAME = Smalltalk
|
||||
BUNDLE_EXTENSION := .stlanguage
|
||||
BUNDLE_INSTALL_DIR:=$(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk/Languages
|
||||
|
||||
Smalltalk_OBJC_FILES = \
|
||||
SmalltalkEngine.m \
|
||||
NSArray+additions.m \
|
||||
NSNumber+additions.m \
|
||||
NSObject+additions.m \
|
||||
STBlock.m \
|
||||
STBlockContext.m \
|
||||
STBytecodeInterpreter.m \
|
||||
STBytecodes.m \
|
||||
STCompiledCode.m \
|
||||
STCompiledMethod.m \
|
||||
STCompiledScript.m \
|
||||
STCompiler.m \
|
||||
STCompilerUtils.m \
|
||||
STExecutionContext.m \
|
||||
STGrammar.m \
|
||||
STLiterals.m \
|
||||
STMessage.m \
|
||||
STMethodContext.m \
|
||||
STScriptObject.m \
|
||||
STStack.m \
|
||||
STUndefinedObject+additions.m \
|
||||
STSelector+additions.m \
|
||||
STSourceReader.m \
|
||||
Externs.m
|
||||
|
||||
Smalltalk_PRINCIPAL_CLASS = SmalltalkEngine
|
||||
|
||||
ADDITIONAL_INCLUDE_DIRS += -I../../Source/Headers
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
-include GNUMakefile.postamble
|
||||
|
||||
STGrammar.m: STGrammar.y
|
||||
$(YACC) -d -pSTC -o$@ $<
|
||||
|
35
Languages/Smalltalk/NSArray+additions.h
Normal file
35
Languages/Smalltalk/NSArray+additions.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
NSArray-additions.h
|
||||
Various methods for NSArray
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
@class STBlock;
|
||||
|
||||
@interface NSArray (STCollecting)
|
||||
- do:(STBlock *)block;
|
||||
- select:(STBlock *)block;
|
||||
- reject:(STBlock *)block;
|
||||
- collect:(STBlock *)block;
|
||||
- detect:(STBlock *)block;
|
||||
@end
|
127
Languages/Smalltalk/NSArray+additions.m
Normal file
127
Languages/Smalltalk/NSArray+additions.m
Normal file
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
NSArray-additions.m
|
||||
Various methods for NSArray
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "NSArray+additions.h"
|
||||
#import "NSNumber+additions.h"
|
||||
#import "STBlock.h"
|
||||
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
|
||||
@implementation NSArray (STCollecting)
|
||||
- do:(STBlock *)block
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
id retval = nil;
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while( (object = [enumerator nextObject]) )
|
||||
{
|
||||
retval = [block valueWith:object];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
- select:(STBlock *)block
|
||||
{
|
||||
NSMutableArray *array;
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
id value;
|
||||
|
||||
array = [NSMutableArray array];
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while( (object = [enumerator nextObject]) )
|
||||
{
|
||||
value = [block valueWith:object];
|
||||
if([(NSNumber *)value isTrue])
|
||||
{
|
||||
[array addObject:object];
|
||||
}
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray:array];
|
||||
}
|
||||
|
||||
- reject:(STBlock *)block
|
||||
{
|
||||
NSMutableArray *array;
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
id value;
|
||||
|
||||
array = [NSMutableArray array];
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while( (object = [enumerator nextObject]) )
|
||||
{
|
||||
value = [block valueWith:object];
|
||||
if([(NSNumber *)value isFalse])
|
||||
{
|
||||
[array addObject:object];
|
||||
}
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray:array];
|
||||
}
|
||||
|
||||
- collect:(STBlock *)block
|
||||
{
|
||||
NSMutableArray *array;
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
id value;
|
||||
|
||||
array = [NSMutableArray array];
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while( (object = [enumerator nextObject]) )
|
||||
{
|
||||
value = [block valueWith:object];
|
||||
[array addObject:value];
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray:array];
|
||||
|
||||
}
|
||||
- detect:(STBlock *)block
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id object;
|
||||
id retval = nil;
|
||||
|
||||
enumerator = [self objectEnumerator];
|
||||
while( (object = [enumerator nextObject]) )
|
||||
{
|
||||
retval = [block valueWith:object];
|
||||
if([(NSNumber *)retval isTrue])
|
||||
{
|
||||
return object;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@end
|
40
Languages/Smalltalk/NSNumber+additions.h
Normal file
40
Languages/Smalltalk/NSNumber+additions.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
NSNumber-additions.h
|
||||
Various methods for NSNumber
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
@class STBlock;
|
||||
|
||||
@interface NSNumber (STSmalltalkAdditions)
|
||||
- ifTrue:(STBlock *)block;
|
||||
- ifFalse:(STBlock *)block;
|
||||
- ifTrue:(STBlock *)trueBlock ifFalse:(STBlock *)falseBlock;
|
||||
- ifFalse:(STBlock *)falseBlock ifTrue:(STBlock *)trueBlock;
|
||||
|
||||
- (BOOL)isTrue;
|
||||
- (BOOL)isFalse;
|
||||
|
||||
- to:(int)number do:(STBlock *)block;
|
||||
- to:(int)number step:(int)step do:(STBlock *)block;
|
||||
@end
|
83
Languages/Smalltalk/NSNumber+additions.m
Normal file
83
Languages/Smalltalk/NSNumber+additions.m
Normal file
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
NSNumber-additions.h
|
||||
Various methods for NSNumber
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
|
||||
#import "NSNumber+additions.h"
|
||||
#import "STBlock.h"
|
||||
#include <math.h>
|
||||
|
||||
@implementation NSNumber (STSmalltalkAdditions)
|
||||
- ifTrue:(STBlock *)block
|
||||
{
|
||||
if([self isTrue])
|
||||
{
|
||||
return [block value];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- ifFalse:(STBlock *)block
|
||||
{
|
||||
if([self isFalse])
|
||||
{
|
||||
return [block value];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
- ifTrue:(STBlock *)trueBlock ifFalse:(STBlock *)falseBlock
|
||||
{
|
||||
if([self isTrue])
|
||||
{
|
||||
return [trueBlock value];
|
||||
}
|
||||
return [falseBlock value];
|
||||
}
|
||||
- ifFalse:(STBlock *)falseBlock ifTrue:(STBlock *)trueBlock
|
||||
{
|
||||
if([self isFalse])
|
||||
{
|
||||
return [falseBlock value];
|
||||
}
|
||||
return [trueBlock value];
|
||||
}
|
||||
|
||||
- (BOOL)isTrue
|
||||
{
|
||||
return ([self intValue] != 0);
|
||||
}
|
||||
- (BOOL)isFalse
|
||||
{
|
||||
return ([self intValue] == 0);
|
||||
}
|
||||
|
||||
/* FIXME: make it work with floats */
|
||||
|
||||
- to:(int)number do:(STBlock *)block
|
||||
{
|
||||
id retval = nil;
|
||||
int i;
|
||||
|
||||
for(i=[self intValue];i<=number;i++)
|
||||
{
|
||||
retval = [block valueWith:[NSNumber numberWithInt:i]];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
- to:(int)number step:(int)step do:(STBlock *)block
|
||||
{
|
||||
id retval = nil;
|
||||
int i;
|
||||
|
||||
for(i=[self intValue];i<=number;i+=step)
|
||||
{
|
||||
retval = [block valueWith:[NSNumber numberWithInt:i]];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@end
|
30
Languages/Smalltalk/NSObject+additions.h
Normal file
30
Languages/Smalltalk/NSObject+additions.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
NSObject-additions.h
|
||||
Various methods for NSObject
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@interface NSObject (STAdditions)
|
||||
- (BOOL)isNil;
|
||||
- (BOOL)notNil;
|
||||
@end
|
24
Languages/Smalltalk/NSObject+additions.m
Normal file
24
Languages/Smalltalk/NSObject+additions.m
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
NSObject-additions.m
|
||||
Various methods for NSObject
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
|
||||
#import "NSObject+additions.h"
|
||||
|
||||
@implementation NSObject (STAdditions)
|
||||
- (BOOL)isNil
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
- (BOOL)notNil
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
61
Languages/Smalltalk/STBlock.h
Normal file
61
Languages/Smalltalk/STBlock.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
STBlock.h
|
||||
Wrapper for STBlockContext to make it invisible
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class STBlockLiteral;
|
||||
@class STBytecodeInterpreter;
|
||||
@class STMethodContext;
|
||||
@class STBlockContext;
|
||||
|
||||
@interface STBlock:NSObject
|
||||
{
|
||||
STBytecodeInterpreter *interpreter;
|
||||
STMethodContext *homeContext;
|
||||
|
||||
unsigned initialIP;
|
||||
unsigned argCount;
|
||||
unsigned stackSize;
|
||||
|
||||
STBlockContext *defaultContext;
|
||||
BOOL defaultContextInUse;
|
||||
}
|
||||
- initWithInterpreter:(STBytecodeInterpreter *)anInterpreter
|
||||
homeContext:(STMethodContext *)context
|
||||
initialIP:(unsigned)ptr
|
||||
info:(STBlockLiteral *)info;
|
||||
|
||||
- (unsigned)argumentCount;
|
||||
|
||||
- value;
|
||||
- valueWith:arg;
|
||||
- valueWith:arg1 with:arg2;
|
||||
- valueWith:arg1 with:arg2 with:arg3;
|
||||
- valueWithArgs:(id *)args count:(unsigned)count;
|
||||
|
||||
- whileTrue:(STBlock *)doBlock;
|
||||
- whileFalse:(STBlock *)doBlock;
|
||||
|
||||
- handler:(STBlock *)handlerBlock;
|
||||
@end
|
228
Languages/Smalltalk/STBlock.m
Normal file
228
Languages/Smalltalk/STBlock.m
Normal file
|
@ -0,0 +1,228 @@
|
|||
/**
|
||||
STBlock.m
|
||||
Wrapper for STBlockContext to make it invisible from the user
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#import "STBlock.h"
|
||||
#import "STLiterals.h"
|
||||
#import "STBlockContext.h"
|
||||
#import "STBytecodeInterpreter.h"
|
||||
#import "STStack.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
|
||||
|
||||
@implementation STBlock
|
||||
- initWithInterpreter:(STBytecodeInterpreter *)anInterpreter
|
||||
homeContext:(STMethodContext *)context
|
||||
initialIP:(unsigned)ptr
|
||||
info:(STBlockLiteral *)info
|
||||
{
|
||||
homeContext = context;
|
||||
argCount = [info argumentCount];
|
||||
stackSize = [info stackSize];
|
||||
initialIP = ptr;
|
||||
interpreter = anInterpreter;
|
||||
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (unsigned)argumentCount
|
||||
{
|
||||
return argCount;
|
||||
}
|
||||
|
||||
- value
|
||||
{
|
||||
if(argCount != 0)
|
||||
{
|
||||
[NSException raise:STScriptingException
|
||||
format:@"Block needs %i arguments", argCount];
|
||||
return nil;
|
||||
}
|
||||
return [self valueWithArgs:(id*)0 count:0];
|
||||
}
|
||||
|
||||
- valueWith:arg
|
||||
{
|
||||
id args[1] = {arg};
|
||||
id retval;
|
||||
|
||||
retval = [self valueWithArgs:args count:1];
|
||||
return retval;
|
||||
}
|
||||
|
||||
- valueWith:arg1 with:arg2
|
||||
{
|
||||
id args[2] = {arg1,arg2};
|
||||
id retval;
|
||||
|
||||
retval = [self valueWithArgs:args count:2];
|
||||
return retval;
|
||||
}
|
||||
|
||||
- valueWith:arg1 with:arg2 with:arg3
|
||||
{
|
||||
id args[3] = {arg1,arg2,arg3};
|
||||
id retval;
|
||||
|
||||
retval = [self valueWithArgs:args count:3];
|
||||
return retval;
|
||||
}
|
||||
|
||||
- valueWith:arg1 with:arg2 with:arg3 with:arg4
|
||||
{
|
||||
id args[4] = {arg1,arg2,arg3,arg4};
|
||||
id retval;
|
||||
|
||||
retval = [self valueWithArgs:args count:4];
|
||||
return retval;
|
||||
}
|
||||
|
||||
- (STBlockContext *)createBlockContext
|
||||
{
|
||||
STBlockContext *context;
|
||||
|
||||
context = [[STBlockContext alloc] initWithInterpreter:interpreter
|
||||
initialIP:initialIP
|
||||
stackSize:stackSize];
|
||||
|
||||
[context setHomeContext:homeContext];
|
||||
|
||||
return context;
|
||||
}
|
||||
- valueWithArgs:(id *)args count:(unsigned)count;
|
||||
{
|
||||
STBlockContext *context = nil;
|
||||
id retval;
|
||||
|
||||
if(argCount != count)
|
||||
{
|
||||
[NSException raise:STScriptingException
|
||||
format:@"Invalid block argument count %i, "
|
||||
@"wants to be %i", count, argCount];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if(!defaultContext)
|
||||
{
|
||||
defaultContext = [self createBlockContext];
|
||||
|
||||
context = RETAIN(defaultContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!defaultContextInUse)
|
||||
{
|
||||
context = RETAIN(defaultContext);
|
||||
defaultContextInUse = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
context = [self createBlockContext];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"new block context %@",context);
|
||||
|
||||
retval = [self evaluateInContext:context arguments:args count:count];
|
||||
|
||||
if(defaultContext == context)
|
||||
{
|
||||
defaultContextInUse = NO;
|
||||
}
|
||||
|
||||
RELEASE(context);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- evaluateInContext:(STBlockContext *)context
|
||||
arguments:(id *)args
|
||||
count:(unsigned)count
|
||||
{
|
||||
STStack *stack;
|
||||
id retval;
|
||||
int i;
|
||||
|
||||
stack = [context stack];
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
[stack push:args[i]];
|
||||
}
|
||||
|
||||
retval = [interpreter valueOfBlockContext:context];
|
||||
[stack empty];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- handler:(STBlock *)handlerBlock
|
||||
{
|
||||
STBlockContext *context;
|
||||
id retval;
|
||||
|
||||
context = [self createBlockContext];
|
||||
|
||||
NS_DURING
|
||||
retval = [self evaluateInContext:context arguments:(id *)nil count:0];
|
||||
NS_HANDLER
|
||||
retval = [handlerBlock valueWith:localException];
|
||||
[context forceReturn];
|
||||
NS_ENDHANDLER
|
||||
|
||||
RELEASE(context);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- whileTrue:(STBlock *)doBlock
|
||||
{
|
||||
id retval;
|
||||
|
||||
while([[self value] boolValue])
|
||||
{
|
||||
retval = [doBlock value];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
- whileFalse:(STBlock *)doBlock
|
||||
{
|
||||
id retval;
|
||||
|
||||
while(! [[self value] boolValue])
|
||||
{
|
||||
retval = [doBlock value];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@end
|
44
Languages/Smalltalk/STBlockContext.h
Normal file
44
Languages/Smalltalk/STBlockContext.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
STBlockContext.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STExecutionContext.h"
|
||||
|
||||
@class STBytecodeInterpreter;
|
||||
@class STMethodContext;
|
||||
|
||||
@interface STBlockContext:STExecutionContext
|
||||
{
|
||||
STBytecodeInterpreter *interpreter;
|
||||
STMethodContext *homeContext; /* owner of this block context */
|
||||
|
||||
unsigned initialIP;
|
||||
}
|
||||
- initWithInterpreter:(STBytecodeInterpreter *)anInterpreter
|
||||
initialIP:(unsigned)pointer
|
||||
stackSize:(unsigned)size;
|
||||
- (void)setHomeContext:(STMethodContext *)context;
|
||||
- (unsigned)initialIP;
|
||||
- (void)initializeIntstructionPointer;
|
||||
|
||||
- (void) forceReturn;
|
||||
@end
|
117
Languages/Smalltalk/STBlockContext.m
Normal file
117
Languages/Smalltalk/STBlockContext.m
Normal file
|
@ -0,0 +1,117 @@
|
|||
/**
|
||||
STBlockContext.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "STBlockContext.h"
|
||||
|
||||
#import "STStack.h"
|
||||
#import "STBytecodeInterpreter.h"
|
||||
#import "STBytecodes.h"
|
||||
#import "STMethodContext.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
@implementation STBlockContext
|
||||
- initWithInterpreter:(STBytecodeInterpreter *)anInterpreter
|
||||
initialIP:(unsigned)pointer
|
||||
stackSize:(unsigned)size
|
||||
{
|
||||
interpreter = RETAIN(anInterpreter);
|
||||
initialIP = pointer;
|
||||
|
||||
[self setInstructionPointer:initialIP];
|
||||
|
||||
return [super initWithStackSize:size];
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(interpreter);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)isBlockContext
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
- (void)setHomeContext:(STMethodContext *)context
|
||||
{
|
||||
ASSIGN(homeContext,context);
|
||||
}
|
||||
- (STMethodContext *)homeContext
|
||||
{
|
||||
return homeContext;
|
||||
}
|
||||
- (void)invalidate
|
||||
{
|
||||
[self setParrentContext:nil];
|
||||
}
|
||||
- (BOOL)isInvalid
|
||||
{
|
||||
return (!parrentContext);
|
||||
}
|
||||
|
||||
- (unsigned)initialIP
|
||||
{
|
||||
return initialIP;
|
||||
}
|
||||
- (void)initializeIntstructionPointer
|
||||
{
|
||||
[self setInstructionPointer:initialIP];
|
||||
}
|
||||
|
||||
- temporaryAtIndex:(unsigned)index;
|
||||
{
|
||||
return [homeContext temporaryAtIndex:index];
|
||||
}
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index;
|
||||
{
|
||||
[homeContext setTemporary:anObject atIndex:index];
|
||||
}
|
||||
|
||||
- externAtIndex:(unsigned)index;
|
||||
{
|
||||
return [homeContext externAtIndex:index];
|
||||
}
|
||||
- (void)setExtern:anObject atIndex:(unsigned)index;
|
||||
{
|
||||
[homeContext setExtern:anObject atIndex:index];
|
||||
}
|
||||
|
||||
- (void) forceReturn
|
||||
{
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"!!! force return from block context");
|
||||
[interpreter forceReturnFromBlockContext];
|
||||
}
|
||||
- (STBytecodes *)bytecodes
|
||||
{
|
||||
return [homeContext bytecodes];
|
||||
}
|
||||
- (id)literalObjectAtIndex:(unsigned)index
|
||||
{
|
||||
return [homeContext literalObjectAtIndex:index];
|
||||
}
|
||||
@end
|
69
Languages/Smalltalk/STBytecodeInterpreter.h
Normal file
69
Languages/Smalltalk/STBytecodeInterpreter.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
STBytecodeInterpreter.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class STCompiledMethod;
|
||||
@class STCompiledCode;
|
||||
@class STBytecodes;
|
||||
@class STExecutionContext;
|
||||
@class STStack;
|
||||
@class STEnvironment;
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface STBytecodeInterpreter:NSObject
|
||||
{
|
||||
STEnvironment *environment; /* scripting environment */
|
||||
|
||||
STExecutionContext *activeContext; /* current execution context */
|
||||
STStack *stack; /* from context */
|
||||
STBytecodes *bytecodes; /* from context */
|
||||
unsigned instructionPointer; /* IP */
|
||||
id receiver;
|
||||
|
||||
int entry;
|
||||
|
||||
BOOL stopRequested;
|
||||
}
|
||||
|
||||
+ (STBytecodeInterpreter *)sharedInterpreter;
|
||||
- (void)setEnvironment:(STEnvironment *)env;
|
||||
|
||||
- executeCompiledMethod:(STCompiledMethod *)aScript;
|
||||
- executeCompiledMethod:(STCompiledMethod *)method
|
||||
withArguments:(NSArray *)args;
|
||||
- executeCompiledCode:(STCompiledCode *)code;
|
||||
|
||||
- (void)setReceiver:(id)anObject;
|
||||
@end
|
||||
|
||||
@class STBlockContext;
|
||||
|
||||
@interface STBytecodeInterpreter(STInterpreterPrivate)
|
||||
- valueOfBlockContext:(STBlockContext *)block;
|
||||
- (void)forceReturnFromBlockContext;
|
||||
@end
|
||||
|
656
Languages/Smalltalk/STBytecodeInterpreter.m
Normal file
656
Languages/Smalltalk/STBytecodeInterpreter.m
Normal file
|
@ -0,0 +1,656 @@
|
|||
/**
|
||||
STBytecodeInterpreter.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STBytecodeInterpreter.h"
|
||||
|
||||
#import "Externs.h"
|
||||
#import "STBlock.h"
|
||||
#import "STBlockContext.h"
|
||||
#import "STLiterals.h"
|
||||
#import "STBytecodes.h"
|
||||
#import "STCompiledMethod.h"
|
||||
#import "STExecutionContext.h"
|
||||
#import "STMethodContext.h"
|
||||
#import "STMessage.h"
|
||||
#import "STStack.h"
|
||||
|
||||
#import <StepTalk/STEnvironment.h>
|
||||
#import <StepTalk/STExterns.h>
|
||||
#import <StepTalk/STFunctions.h>
|
||||
#import <StepTalk/NSInvocation+additions.h>
|
||||
#import <StepTalk/STScripting.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSInvocation.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <objc/encoding.h>
|
||||
|
||||
@interface STBytecodeInterpreter(STPrivateMethods)
|
||||
- (void)fetchContextRegisters;
|
||||
|
||||
- (short)fetchBytecode;
|
||||
- (BOOL)dispatchBytecode:(STBytecode)bytecode;
|
||||
- (void)invalidBytecode:(STBytecode)bytecode;
|
||||
|
||||
- (void)setInstructionPointer:(unsigned)newIP;
|
||||
- (unsigned) instructionPointer;
|
||||
|
||||
- temporaryAtIndex:(unsigned)index;
|
||||
- externAtIndex:(unsigned)index;
|
||||
- literalAtIndex:(unsigned)index;
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index;
|
||||
- (void)registerObject:anObject withName:(NSString *)name;
|
||||
|
||||
- (void)sendSelectorAtIndex:(unsigned)index withArgs:(unsigned)argCount;
|
||||
|
||||
- (void)resolveExternReferencesFrom:(NSArray *)array;
|
||||
|
||||
- (void)setArgumentsFromArray:(NSArray *)args;
|
||||
- (void)prepareHomeContextWithMethod:(STCompiledMethod *)aMethod;
|
||||
- (id) interpretInContext:(STExecutionContext *)context;
|
||||
- (void)setNewActiveContext:(STExecutionContext *)newContext;
|
||||
- (void)fetchContextRegisters;
|
||||
- (void)blockCopyWithInfo:(STBlockLiteral *)info;
|
||||
- (id) valueOfBlockContext:(STBlockContext *)block;
|
||||
- (void)blockReturnValue:(id)value;
|
||||
- (void)returnValue:(id)value;
|
||||
- (void)returnToContext:(STExecutionContext *)context;
|
||||
@end
|
||||
|
||||
static STBytecodeInterpreter *sharedInterpreter = nil;
|
||||
|
||||
static SEL sendSelectorAtIndexSel;
|
||||
static IMP sendSelectorAtIndexImp;
|
||||
static SEL dispatchBytecodeSel;
|
||||
static IMP dispatchBytecodeImp;
|
||||
static SEL pushSel;
|
||||
static IMP pushImp;
|
||||
static SEL popSel;
|
||||
static id (*popImp)(id obj, SEL sel);
|
||||
|
||||
@implementation STBytecodeInterpreter
|
||||
+ (void)initialize
|
||||
{
|
||||
sendSelectorAtIndexSel = @selector(sendSelectorAtIndex:withArgCount:);
|
||||
pushSel = @selector(push:);
|
||||
popSel = @selector(pop);
|
||||
|
||||
sendSelectorAtIndexImp = [STBytecodeInterpreter instanceMethodForSelector:sendSelectorAtIndexSel];
|
||||
pushImp = [STStack instanceMethodForSelector:pushSel];
|
||||
popImp = [STStack instanceMethodForSelector:popSel];
|
||||
}
|
||||
|
||||
+ (STBytecodeInterpreter *)sharedInterpreter
|
||||
{
|
||||
if(!sharedInterpreter)
|
||||
{
|
||||
sharedInterpreter = [[self alloc] init];
|
||||
}
|
||||
return sharedInterpreter;
|
||||
}
|
||||
|
||||
- (void)setEnvironment:(STEnvironment *)env
|
||||
{
|
||||
ASSIGN(environment,env);
|
||||
}
|
||||
|
||||
- executeCompiledMethod:(STCompiledMethod *)aScript
|
||||
{
|
||||
return [self executeCompiledMethod:aScript withArguments:nil];
|
||||
}
|
||||
|
||||
- executeCompiledMethod:(STCompiledMethod *)method
|
||||
withArguments:(NSArray *)args
|
||||
{
|
||||
STMethodContext *newContext;
|
||||
id retval;
|
||||
|
||||
if(!environment)
|
||||
{
|
||||
[NSException raise:STInterpreterGenericException
|
||||
format:@"No execution environment set"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",@"Executing method %@ with %i args",
|
||||
[method selector],[args count]);
|
||||
|
||||
if(!method)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if([args count] != [method argumentCount])
|
||||
{
|
||||
[NSException raise:STInterpreterGenericException
|
||||
format:@"Invalid argument count %i(%i) for method %@ ",
|
||||
[args count],[method argumentCount], [method selector]];
|
||||
}
|
||||
|
||||
newContext = [STMethodContext methodContextWithMethod:method
|
||||
environment:environment];
|
||||
|
||||
[newContext setArgumentsFromArray:args];
|
||||
|
||||
retval = [self interpretInContext:newContext];
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- executeCompiledCode:(STCompiledCode *)code
|
||||
{
|
||||
STCompiledMethod *method;
|
||||
STMethodContext *newContext;
|
||||
STMessage *pattern;
|
||||
id retval;
|
||||
|
||||
pattern = [STMessage messageWithSelector:@"_anonymous_code"
|
||||
arguments:nil];
|
||||
|
||||
method = [STCompiledMethod methodWithCode:code
|
||||
messagePattern:pattern];
|
||||
|
||||
return [self executeCompiledMethod:method withArguments:nil];
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Interpret
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
- (id)interpretInContext:(STExecutionContext *)newContext
|
||||
{
|
||||
STBytecode bytecode;
|
||||
id retval;
|
||||
|
||||
entry++;
|
||||
NSDebugLLog(@"STBytecodeInterpreter", @"Interpreter entry %i", entry);
|
||||
|
||||
[newContext setParrentContext:activeContext];
|
||||
|
||||
[self setNewActiveContext:newContext];
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter", @"IP %i %x", instructionPointer, [bytecodes length]);
|
||||
|
||||
if(!bytecodes)
|
||||
{
|
||||
[NSException raise:STInterpreterGenericException
|
||||
format:@"No bytecodes"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
stopRequested = NO;
|
||||
|
||||
do
|
||||
{
|
||||
bytecode = [bytecodes fetchNextBytecodeAtPointer:&instructionPointer];
|
||||
|
||||
if(stopRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
} while( [self dispatchBytecode:bytecode] );
|
||||
|
||||
if(!stopRequested)
|
||||
{
|
||||
retval = [stack pop];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugLLog(@"STBytecode interpreter",@"Stop requested");
|
||||
|
||||
retval = nil;
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"Returning '%@' from interpreter (entry %i)",retval,entry);
|
||||
|
||||
entry --;
|
||||
return retval;
|
||||
}
|
||||
|
||||
- (void)halt
|
||||
{
|
||||
NSDebugLLog(@"STBytecode interpreter",@"Halt!");
|
||||
stopRequested = YES;
|
||||
}
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Context manipulation
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (void)setNewActiveContext:(STExecutionContext *)newContext
|
||||
{
|
||||
|
||||
NSDebugLLog(@"STExecutionContext", @"Switch from context %@ to context %@",
|
||||
activeContext, newContext);
|
||||
|
||||
[activeContext setInstructionPointer:instructionPointer];
|
||||
|
||||
if( [newContext isInvalid])
|
||||
{
|
||||
[NSException raise:STInterpreterGenericException
|
||||
format:@"Invalid context"];
|
||||
}
|
||||
|
||||
ASSIGN(activeContext,newContext);
|
||||
|
||||
if(activeContext)
|
||||
{
|
||||
stack = [activeContext stack];
|
||||
|
||||
if(!stack)
|
||||
{
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"No execution stack"];
|
||||
}
|
||||
|
||||
instructionPointer = [activeContext instructionPointer];
|
||||
|
||||
bytecodes = [activeContext bytecodes];
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionPointer = 0;
|
||||
bytecodes = nil;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Return
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (void)returnValue:(id)value
|
||||
{
|
||||
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ return value '%@' from method",
|
||||
activeContext,value);
|
||||
|
||||
[self returnToContext:[activeContext parrentContext]];
|
||||
[stack push:value];
|
||||
}
|
||||
|
||||
- (void)returnToContext:(STExecutionContext *)context
|
||||
{
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ return to context %@",activeContext,context);
|
||||
|
||||
|
||||
[activeContext invalidate];
|
||||
|
||||
[self setNewActiveContext:context];
|
||||
}
|
||||
|
||||
- (unsigned) instructionPointer
|
||||
{
|
||||
return instructionPointer;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
Variables manipulation
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
- (id)temporaryAtIndex:(unsigned)index
|
||||
{
|
||||
id object = [activeContext temporaryAtIndex:index];
|
||||
return object;
|
||||
}
|
||||
|
||||
- (id)literalAtIndex:(unsigned)index
|
||||
{
|
||||
return [activeContext literalObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (id)externAtIndex:(unsigned)index
|
||||
{
|
||||
return [activeContext externAtIndex:index];
|
||||
}
|
||||
|
||||
|
||||
- (void)setReceiver:(id)anObject
|
||||
{
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"set receiver '%@'",anObject);
|
||||
ASSIGN(receiver,anObject);
|
||||
}
|
||||
|
||||
/* FIXME: ---------------------------------------------------------------------
|
||||
* Block manipulation
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
- (void)blockCopyWithInfo:(STBlockLiteral *)info
|
||||
{
|
||||
unsigned ptr;
|
||||
STBlock *block;
|
||||
|
||||
ptr = instructionPointer + STLongJumpBytecodeSize;
|
||||
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ create block",activeContext);
|
||||
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ argc:%i stack:%i ip:0x%04x",
|
||||
activeContext,
|
||||
[info argumentCount],
|
||||
[info stackSize],
|
||||
ptr);
|
||||
|
||||
|
||||
block = [STBlock alloc];
|
||||
|
||||
[block initWithInterpreter:self
|
||||
homeContext:[activeContext homeContext]
|
||||
initialIP:ptr
|
||||
info:info];
|
||||
|
||||
[stack push:block];
|
||||
}
|
||||
|
||||
- (id)valueOfBlockContext:(STBlockContext *)block
|
||||
{
|
||||
id retval;
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",@"evaluating block context");
|
||||
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ evaluate block %@",
|
||||
activeContext, block);
|
||||
|
||||
[block setParrentContext:activeContext];
|
||||
[block initializeIntstructionPointer];
|
||||
|
||||
retval = [self interpretInContext:block];
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"Returning '%@' from block",retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- (void)forceReturnFromBlockContext
|
||||
{
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"Forced return from block");
|
||||
[self blockReturnValue:[stack pop]];
|
||||
}
|
||||
|
||||
- (void)blockReturnValue:(id)value
|
||||
{
|
||||
NSDebugLLog(@"STExecutionContext",
|
||||
@"%@ block return value '%@' to parrent",
|
||||
activeContext,value);
|
||||
|
||||
[self returnToContext:[activeContext parrentContext]];
|
||||
[stack push:value];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
send selector (see also STEnvironment class)
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (void)sendSelectorAtIndex:(unsigned)selIndex withArgCount:(unsigned)argCount
|
||||
{
|
||||
NSString *selector;
|
||||
NSInvocation *invocation;
|
||||
id target;
|
||||
int index;
|
||||
id object;
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@"send selector '%@' with %i args'",
|
||||
[self literalAtIndex:selIndex],argCount);
|
||||
|
||||
target = [stack valueFromTop:argCount];
|
||||
|
||||
/* FIXME */
|
||||
if(!target)
|
||||
{
|
||||
target = STNil;
|
||||
}
|
||||
|
||||
selector = [self literalAtIndex:selIndex];
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@" %s receiver:%@ (%s) selector:%@",
|
||||
[receiver isProxy] ? "proxy for" : "",
|
||||
target,
|
||||
[target name],
|
||||
selector);
|
||||
|
||||
selector = [environment translateSelector:selector forReceiver:target];
|
||||
|
||||
invocation = [NSInvocation invocationWithTarget:target
|
||||
selectorName:selector];
|
||||
|
||||
if(!invocation)
|
||||
{
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"Should not send selector '%@' to "
|
||||
@"receiver of type %@ (could not create invocation)",
|
||||
selector,[target className]];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(index = argCount + 1; index > 1; index--)
|
||||
{
|
||||
|
||||
object = [stack pop];
|
||||
|
||||
if(object == STNil)
|
||||
{
|
||||
object = nil;
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@" argument %2i: '%@'",index - 2, object);
|
||||
|
||||
[invocation setArgumentAsObject:object atIndex:index];
|
||||
}
|
||||
|
||||
/* ----------------------------
|
||||
* invoke it!
|
||||
* ----------------------------
|
||||
*/
|
||||
|
||||
NSDebugLLog(@"STSending",@" invoking... (%@)",invocation);
|
||||
[invocation invoke];
|
||||
|
||||
/* FIXME */
|
||||
if(!stopRequested)
|
||||
{
|
||||
/* pop the receiver from the stack */
|
||||
[stack pop];
|
||||
[stack push: [invocation returnValueAsObject]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
Bytecode manipulation
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define STDebugBytecode(bc) \
|
||||
NSDebugLLog(@"STBytecodeInterpreter", \
|
||||
@"#%04x %@", \
|
||||
(bc).pointer, \
|
||||
STDissasembleBytecode(bc))
|
||||
|
||||
#define STDebugBytecodeWith(bc,object) \
|
||||
NSDebugLLog(@"STBytecodeInterpreter", \
|
||||
@"#%04x %@ (%@)", \
|
||||
(bc).pointer, \
|
||||
STDissasembleBytecode(bc), \
|
||||
(object))
|
||||
|
||||
#define STPush(s, v) (*pushImp)(s, pushSel, v)
|
||||
// #define STPush(s, v) [s push:v]
|
||||
|
||||
#define STPop(s) (*popImp)(s, popSel)
|
||||
// #define STPop(s) [s pop]
|
||||
|
||||
- (BOOL)dispatchBytecode:(STBytecode)bytecode
|
||||
{
|
||||
id object;
|
||||
|
||||
switch(bytecode.code)
|
||||
{
|
||||
case STLongJumpBytecode:
|
||||
{
|
||||
int offset = STLongJumpOffset(bytecode.arg1,bytecode.arg2)
|
||||
- STLongJumpBytecodeSize;
|
||||
|
||||
STDebugBytecode(bytecode);
|
||||
instructionPointer+=offset;
|
||||
break;
|
||||
}
|
||||
|
||||
case STPushReceiverBytecode:
|
||||
STDebugBytecodeWith(bytecode,receiver);
|
||||
STPush(stack, receiver);
|
||||
break;
|
||||
|
||||
case STPushNilBytecode:
|
||||
STDebugBytecodeWith(bytecode,receiver);
|
||||
STPush(stack,nil);
|
||||
break;
|
||||
|
||||
case STPushTrueBytecode:
|
||||
STDebugBytecodeWith(bytecode,receiver);
|
||||
STPush(stack,[NSNumber numberWithInt:YES]);
|
||||
break;
|
||||
|
||||
case STPushFalseBytecode:
|
||||
STDebugBytecodeWith(bytecode,receiver);
|
||||
STPush(stack,[NSNumber numberWithInt:NO]);
|
||||
break;
|
||||
|
||||
case STPushRecVarBytecode:
|
||||
object = [receiver instanceVariableAtIndex:bytecode.arg1];
|
||||
STDebugBytecodeWith(bytecode,object);
|
||||
STPush(stack,object);
|
||||
break;
|
||||
|
||||
case STPushExternBytecode:
|
||||
object = [self externAtIndex:bytecode.arg1];
|
||||
STDebugBytecodeWith(bytecode,object);
|
||||
STPush(stack,object);
|
||||
break;
|
||||
|
||||
case STPushTemporaryBytecode:
|
||||
object = [self temporaryAtIndex:bytecode.arg1];
|
||||
STPush(stack,object);
|
||||
STDebugBytecodeWith(bytecode,object);
|
||||
break;
|
||||
|
||||
case STPushLiteralBytecode:
|
||||
object = [self literalAtIndex:bytecode.arg1];
|
||||
STDebugBytecodeWith(bytecode,object);
|
||||
STPush(stack,object);
|
||||
break;
|
||||
|
||||
case STPopAndStoreRecVarBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[receiver setInstanceVariable:STPop(stack)
|
||||
atIndex:bytecode.arg1];
|
||||
break;
|
||||
|
||||
case STPopAndStoreExternBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[activeContext setExtern:STPop(stack) atIndex:bytecode.arg1];
|
||||
break;
|
||||
|
||||
case STPopAndStoreTempBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[activeContext setTemporary:STPop(stack) atIndex:bytecode.arg1];
|
||||
break;
|
||||
|
||||
case STSendSelectorBytecode:
|
||||
STDebugBytecodeWith(bytecode,
|
||||
[self literalAtIndex:bytecode.arg1]);
|
||||
|
||||
(*sendSelectorAtIndexImp)(self, sendSelectorAtIndexSel,
|
||||
bytecode.arg1,bytecode.arg2);
|
||||
/*
|
||||
[self sendSelectorAtIndex:bytecode.arg1
|
||||
withArgCount:bytecode.arg2];
|
||||
*/ break;
|
||||
|
||||
case STSuperSendSelectorBytecode: /* FIXME: not implemented */
|
||||
[self invalidBytecode:bytecode];
|
||||
break;
|
||||
|
||||
case STDupBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[stack duplicateTop];
|
||||
break;
|
||||
|
||||
|
||||
case STPopStackBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[stack pop];
|
||||
break;
|
||||
|
||||
case STReturnBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[self returnValue:[stack pop]];
|
||||
return NO;
|
||||
|
||||
case STReturnBlockBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[self blockReturnValue:[stack pop]];
|
||||
return NO;
|
||||
|
||||
case STBlockCopyBytecode:
|
||||
STDebugBytecode(bytecode);
|
||||
[self blockCopyWithInfo:[stack pop]];
|
||||
break;
|
||||
|
||||
default:
|
||||
[self invalidBytecode:bytecode];
|
||||
break;
|
||||
};
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)invalidBytecode:(STBytecode)bytecode
|
||||
{
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"invalid bytecode (0x%02x) at 0x%06x",
|
||||
bytecode.code,bytecode.pointer];
|
||||
}
|
||||
@end
|
||||
|
||||
|
91
Languages/Smalltalk/STBytecodes.h
Normal file
91
Languages/Smalltalk/STBytecodes.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
STBytecodes.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSData.h>
|
||||
|
||||
|
||||
/* Bytecode table */
|
||||
/*
|
||||
#define STReceiverConstant 0x00
|
||||
#define STTrueConstant 0x01
|
||||
#define STFalseConstant 0x02
|
||||
#define STNilConstant 0x03
|
||||
*/
|
||||
#define STPushReceiverBytecode 0x00 /* push self */
|
||||
#define STPushNilBytecode 0x01
|
||||
#define STPushTrueBytecode 0x02
|
||||
#define STPushFalseBytecode 0x03
|
||||
/* 0x00 - 0x07 receiver,true,false,nil,
|
||||
-1,0,1,2 */
|
||||
#define STPushRecVarBytecode 0x08 /* recvar index */
|
||||
#define STPushExternBytecode 0x09 /* extern index */
|
||||
#define STPushTemporaryBytecode 0x0a /* temp index */
|
||||
#define STPushLiteralBytecode 0x0b /* lit index */
|
||||
#define STPopAndStoreRecVarBytecode 0x0c /* recvar index */
|
||||
#define STPopAndStoreExternBytecode 0x0d /* extern index */
|
||||
#define STPopAndStoreTempBytecode 0x0e /* temp index */
|
||||
/* 0x0f reserved */
|
||||
#define STSendSelectorBytecode 0x10 /* lit index, arg count */
|
||||
#define STSuperSendSelectorBytecode 0x11 /* lit index, arg count */
|
||||
#define STBlockCopyBytecode 0x12
|
||||
#define STLongJumpBytecode 0x13 /* byte 1, byte 2 */
|
||||
#define STDupBytecode 0x14
|
||||
#define STPopStackBytecode 0x15
|
||||
#define STReturnBytecode 0x16
|
||||
#define STReturnBlockBytecode 0x17
|
||||
/* 0x18-0x27 reserved single bytecodes */
|
||||
/* 0x27-0xfe reserved */
|
||||
#define STBreakpointBytecode 0xff
|
||||
|
||||
#define STLongJumpOffset(arg1, arg2) \
|
||||
( (((arg1) & 0xff) << 8) | ((arg2) & 0xff) )
|
||||
#define STLongJumpFirstByte(offset)\
|
||||
( ((offset) >> 8) & 0xff )
|
||||
#define STLongJumpSecondByte(offset)\
|
||||
( (offset) & 0xff )
|
||||
#define STLongJumpBytecodeSize 3
|
||||
|
||||
@class NSArray;
|
||||
@class NSString;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short code;
|
||||
unsigned short arg1;
|
||||
unsigned short arg2;
|
||||
unsigned pointer;
|
||||
} STBytecode;
|
||||
|
||||
extern NSArray *STBytecodeNames;
|
||||
extern NSString *STBytecodeName(short code);
|
||||
extern NSString *STDissasembleBytecode(STBytecode bytecode);
|
||||
|
||||
@interface STBytecodes:NSData
|
||||
{
|
||||
NSData *bytes;
|
||||
}
|
||||
- (STBytecode)fetchNextBytecodeAtPointer:(unsigned *)pointer;
|
||||
@end
|
||||
|
||||
|
||||
|
270
Languages/Smalltalk/STBytecodes.m
Normal file
270
Languages/Smalltalk/STBytecodes.m
Normal file
|
@ -0,0 +1,270 @@
|
|||
/**
|
||||
STBytecodes.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STBytecodes.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import "Externs.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
|
||||
NSArray *STBytecodeNames;
|
||||
|
||||
static void initNamesArray(void)
|
||||
{
|
||||
NSString *invalid = @"invalid bytecode";
|
||||
NSMutableArray *array;
|
||||
int i;
|
||||
|
||||
array = [NSMutableArray arrayWithCapacity:256];
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
[array insertObject:invalid atIndex:i];
|
||||
}
|
||||
|
||||
[array replaceObjectAtIndex:STPushReceiverBytecode
|
||||
withObject:@"push self"];
|
||||
[array replaceObjectAtIndex:STPushNilBytecode
|
||||
withObject:@"push nil"];
|
||||
[array replaceObjectAtIndex:STPushTrueBytecode
|
||||
withObject:@"push true"];
|
||||
[array replaceObjectAtIndex:STPushFalseBytecode
|
||||
withObject:@"push false"];
|
||||
[array replaceObjectAtIndex:STPushRecVarBytecode
|
||||
withObject:@"push ivar"];
|
||||
[array replaceObjectAtIndex:STPushExternBytecode
|
||||
withObject:@"push extern"];
|
||||
[array replaceObjectAtIndex:STPushTemporaryBytecode
|
||||
withObject:@"push temporary"];
|
||||
[array replaceObjectAtIndex:STPushLiteralBytecode
|
||||
withObject:@"push literal"];
|
||||
[array replaceObjectAtIndex:STPopAndStoreRecVarBytecode
|
||||
withObject:@"pop and store ivar"];
|
||||
[array replaceObjectAtIndex:STPopAndStoreExternBytecode
|
||||
withObject:@"pop and store extern"];
|
||||
[array replaceObjectAtIndex:STPopAndStoreTempBytecode
|
||||
withObject:@"pop and store temp"];
|
||||
[array replaceObjectAtIndex:STSendSelectorBytecode
|
||||
withObject:@"send selector"];
|
||||
[array replaceObjectAtIndex:STSuperSendSelectorBytecode
|
||||
withObject:@"send super selector"];
|
||||
[array replaceObjectAtIndex:STBlockCopyBytecode
|
||||
withObject:@"block copy"];
|
||||
[array replaceObjectAtIndex:STDupBytecode
|
||||
withObject:@"dup"];
|
||||
[array replaceObjectAtIndex:STPopStackBytecode
|
||||
withObject:@"pop"];
|
||||
[array replaceObjectAtIndex:STReturnBytecode
|
||||
withObject:@"return"];
|
||||
[array replaceObjectAtIndex:STReturnBlockBytecode
|
||||
withObject:@"return from block"];
|
||||
[array replaceObjectAtIndex:STBreakpointBytecode
|
||||
withObject:@"breakpoint"];
|
||||
[array replaceObjectAtIndex:STLongJumpBytecode
|
||||
withObject:@"long jump"];
|
||||
|
||||
STBytecodeNames = [[NSArray alloc] initWithArray:array];
|
||||
}
|
||||
|
||||
|
||||
NSString *STBytecodeName(short code)
|
||||
{
|
||||
static NSString *invalid = @"invalid bytecode";
|
||||
NSString *name;
|
||||
|
||||
if( code < 0 || code > [STBytecodeNames count] )
|
||||
{
|
||||
return invalid;
|
||||
}
|
||||
|
||||
name = [STBytecodeNames objectAtIndex:code];
|
||||
|
||||
if(name == nil)
|
||||
{
|
||||
return invalid;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
NSString *STDissasembleBytecode(STBytecode bytecode)
|
||||
{
|
||||
NSString *str;
|
||||
|
||||
str = STBytecodeName(bytecode.code);
|
||||
|
||||
switch(bytecode.code)
|
||||
{
|
||||
case STLongJumpBytecode:
|
||||
{
|
||||
int offset = STLongJumpOffset(bytecode.arg1,bytecode.arg2);
|
||||
return [NSString stringWithFormat:@"%@ %i (0x%06x)",
|
||||
str, offset, bytecode.pointer+offset];
|
||||
}
|
||||
case STSendSelectorBytecode:
|
||||
case STSuperSendSelectorBytecode:
|
||||
return [NSString stringWithFormat:@"%@ %i with %i args",
|
||||
str, bytecode.arg1, bytecode.arg2];
|
||||
case STPushRecVarBytecode:
|
||||
case STPushExternBytecode:
|
||||
case STPushTemporaryBytecode:
|
||||
case STPushLiteralBytecode:
|
||||
case STPopAndStoreRecVarBytecode:
|
||||
case STPopAndStoreExternBytecode:
|
||||
case STPopAndStoreTempBytecode:
|
||||
return [NSString stringWithFormat:@"%@ %i",
|
||||
str, bytecode.arg1];
|
||||
case STPushReceiverBytecode:
|
||||
case STPushNilBytecode:
|
||||
case STPushTrueBytecode:
|
||||
case STPushFalseBytecode:
|
||||
case STBlockCopyBytecode:
|
||||
case STDupBytecode:
|
||||
case STPopStackBytecode:
|
||||
case STReturnBytecode:
|
||||
case STReturnBlockBytecode:
|
||||
case STBreakpointBytecode:
|
||||
return str;
|
||||
default:
|
||||
return [NSString stringWithFormat:@"invalid (0x%02x)",
|
||||
bytecode.code];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@implementation STBytecodes
|
||||
+ (void)initialize
|
||||
{
|
||||
initNamesArray();
|
||||
}
|
||||
/*
|
||||
- (id) initWithBytesNoCopy: (void*)someBytes
|
||||
length: (unsigned)length
|
||||
fromZone: (NSZone*)zone
|
||||
{
|
||||
bytes = [[NSData alloc] initWithBytesNoCopy:someBytes
|
||||
length:length
|
||||
fromZone:zone];
|
||||
return self;
|
||||
}
|
||||
*/
|
||||
- (id) initWithBytes: (const void*)someBytes
|
||||
length: (unsigned int)length
|
||||
{
|
||||
bytes = [[NSData alloc] initWithBytes:someBytes
|
||||
length:length];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(bytes);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (const void *)bytes
|
||||
{
|
||||
return [bytes bytes];
|
||||
}
|
||||
- (unsigned) length
|
||||
{
|
||||
return [bytes length];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [bytes description];
|
||||
}
|
||||
|
||||
- (STBytecode)fetchNextBytecodeAtPointer:(unsigned *)pointer
|
||||
{
|
||||
STBytecode bytecode;
|
||||
const char *bytesPtr = (const char *)[bytes bytes];
|
||||
unsigned length = [self length];
|
||||
|
||||
if(*pointer < length)
|
||||
{
|
||||
bytecode.pointer = *pointer;
|
||||
bytecode.code = bytesPtr[(*pointer)++];
|
||||
|
||||
switch(bytecode.code)
|
||||
{
|
||||
case STLongJumpBytecode:
|
||||
case STSendSelectorBytecode:
|
||||
case STSuperSendSelectorBytecode:
|
||||
if(*pointer + 2 >= length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bytecode.arg1 = bytesPtr[(*pointer)++];
|
||||
bytecode.arg2 = bytesPtr[(*pointer)++];
|
||||
return bytecode;
|
||||
case STPushRecVarBytecode:
|
||||
case STPushExternBytecode:
|
||||
case STPushTemporaryBytecode:
|
||||
case STPushLiteralBytecode:
|
||||
case STPopAndStoreRecVarBytecode:
|
||||
case STPopAndStoreExternBytecode:
|
||||
case STPopAndStoreTempBytecode:
|
||||
if(*pointer + 1 >= length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
bytecode.arg1 = bytesPtr[(*pointer)++];
|
||||
bytecode.arg2 = 0;
|
||||
return bytecode;
|
||||
case STPushReceiverBytecode:
|
||||
case STPushNilBytecode:
|
||||
case STPushTrueBytecode:
|
||||
case STPushFalseBytecode:
|
||||
case STBlockCopyBytecode:
|
||||
case STDupBytecode:
|
||||
case STPopStackBytecode:
|
||||
case STReturnBytecode:
|
||||
case STReturnBlockBytecode:
|
||||
case STBreakpointBytecode:
|
||||
bytecode.arg1 = 0;
|
||||
bytecode.arg2 = 0;
|
||||
return bytecode;
|
||||
default:
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"Invalid bytecode 0x%02x at 0x%06x",
|
||||
bytecode.code,*pointer-1];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"Instruction pointer 0x%06x out of bounds (0x%06x)",
|
||||
*pointer,length];
|
||||
return bytecode;
|
||||
}
|
||||
@end
|
||||
|
50
Languages/Smalltalk/STCompiledCode.h
Normal file
50
Languages/Smalltalk/STCompiledCode.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
STCompiledCode.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSData;
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
@class STBytecodes;
|
||||
|
||||
@interface STCompiledCode:NSObject
|
||||
{
|
||||
STBytecodes *bytecodes;
|
||||
NSArray *literals;
|
||||
NSMutableArray *externRefs;
|
||||
short tempCount;
|
||||
short stackSize;
|
||||
}
|
||||
- initWithBytecodesData:(NSData *)data
|
||||
literals:(NSArray *)anArray
|
||||
temporariesCount:(unsigned)count
|
||||
stackSize:(unsigned)size
|
||||
externReferences:(NSMutableArray *)refs;
|
||||
|
||||
- (STBytecodes *)bytecodes;
|
||||
- (unsigned)temporariesCount;
|
||||
- (unsigned)stackSize;
|
||||
- (id)literalObjectAtIndex:(unsigned)index;
|
||||
- (NSMutableArray *)externReferences;
|
||||
- (NSArray *)literals;
|
||||
@end
|
83
Languages/Smalltalk/STCompiledCode.m
Normal file
83
Languages/Smalltalk/STCompiledCode.m
Normal file
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
STCompiledCode.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STCompiledCode.h"
|
||||
#import "STBytecodes.h"
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
@implementation STCompiledCode
|
||||
- initWithBytecodesData:(NSData *)data
|
||||
literals:(NSArray *)anArray
|
||||
temporariesCount:(unsigned)count
|
||||
stackSize:(unsigned)size
|
||||
externReferences:(NSMutableArray *)refs
|
||||
{
|
||||
[super init];
|
||||
|
||||
bytecodes = [[STBytecodes alloc] initWithData:RETAIN(data)];
|
||||
literals = RETAIN(anArray);
|
||||
tempCount = count;
|
||||
stackSize = size;
|
||||
ASSIGN(externRefs,refs);
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(bytecodes);
|
||||
RELEASE(literals);
|
||||
RELEASE(externRefs);
|
||||
[super dealloc];
|
||||
}
|
||||
- (STBytecodes *)bytecodes
|
||||
{
|
||||
return bytecodes;
|
||||
}
|
||||
|
||||
- (unsigned)temporariesCount
|
||||
{
|
||||
return tempCount;
|
||||
}
|
||||
- (unsigned)stackSize
|
||||
{
|
||||
return stackSize;
|
||||
}
|
||||
- (NSArray *)literals
|
||||
{
|
||||
return literals;
|
||||
}
|
||||
- (id)literalObjectAtIndex:(unsigned)index
|
||||
{
|
||||
return [literals objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (NSMutableArray *)externReferences
|
||||
{
|
||||
return externRefs;
|
||||
}
|
||||
@end
|
46
Languages/Smalltalk/STCompiledMethod.h
Normal file
46
Languages/Smalltalk/STCompiledMethod.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
STCompiledMethod.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import "STCompiledCode.h"
|
||||
|
||||
@class STMessage;
|
||||
|
||||
@interface STCompiledMethod:STCompiledCode
|
||||
{
|
||||
NSString *selector;
|
||||
short argCount;
|
||||
|
||||
// unsigned primitive;
|
||||
}
|
||||
+ methodWithCode:(STCompiledCode *)code messagePattern:(STMessage *)pattern;
|
||||
|
||||
- initWithSelector:(NSString *)sel
|
||||
argumentCount:(unsigned)aCount
|
||||
bytecodesData:(NSData *)data
|
||||
literals:(NSArray *)anArray
|
||||
temporariesCount:(unsigned)tCount
|
||||
stackSize:(unsigned)size
|
||||
externReferences:(NSMutableArray *)refs;
|
||||
|
||||
- (NSString *)selector;
|
||||
- (unsigned)argumentCount;
|
||||
@end
|
120
Languages/Smalltalk/STCompiledMethod.m
Normal file
120
Languages/Smalltalk/STCompiledMethod.m
Normal file
|
@ -0,0 +1,120 @@
|
|||
/**
|
||||
STCompiledMethod.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STCompiledMethod.h"
|
||||
|
||||
#import "STMessage.h"
|
||||
#import "STBytecodes.h"
|
||||
|
||||
#import <StepTalk/STScripting.h>
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSData.h>
|
||||
|
||||
@implementation STCompiledMethod
|
||||
+ methodWithCode:(STCompiledCode *)code messagePattern:(STMessage *)pattern
|
||||
{
|
||||
STCompiledMethod *method;
|
||||
|
||||
method = [STCompiledMethod alloc];
|
||||
|
||||
[method initWithSelector:[pattern selector]
|
||||
argumentCount:[[pattern arguments] count]
|
||||
bytecodesData:[code bytecodes]
|
||||
literals:[code literals]
|
||||
temporariesCount:[code temporariesCount]
|
||||
stackSize:[code stackSize]
|
||||
externReferences:[code externReferences]];
|
||||
|
||||
|
||||
return AUTORELEASE(method);
|
||||
}
|
||||
|
||||
- initWithSelector:(NSString *)sel
|
||||
argumentCount:(unsigned)aCount
|
||||
bytecodesData:(NSData *)data
|
||||
literals:(NSArray *)anArray
|
||||
temporariesCount:(unsigned)tCount
|
||||
stackSize:(unsigned)size
|
||||
externReferences:(NSMutableArray *)refs;
|
||||
{
|
||||
[super initWithBytecodesData:data
|
||||
literals:anArray
|
||||
temporariesCount:tCount
|
||||
stackSize:size
|
||||
externReferences:refs];
|
||||
|
||||
selector = RETAIN(sel);
|
||||
argCount = aCount;
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(selector);
|
||||
[super dealloc];
|
||||
}
|
||||
- (NSString *)selector
|
||||
{
|
||||
return selector;
|
||||
}
|
||||
|
||||
- (void)setSelector:(NSString *)newSelector
|
||||
{
|
||||
ASSIGN(selector,newSelector);
|
||||
}
|
||||
- (unsigned)argumentCount
|
||||
{
|
||||
return argCount;
|
||||
}
|
||||
- (void)setArgumentCount:(unsigned)count
|
||||
{
|
||||
argCount = count;
|
||||
}
|
||||
- (NSString*)description
|
||||
{
|
||||
NSMutableString *desc = [NSMutableString string];
|
||||
|
||||
[desc appendFormat:@"%s:\n"
|
||||
@"Selector = %@\n"
|
||||
@"Literals Count = %i\n"
|
||||
@"Literals = %@\n"
|
||||
@"External References = %@\n"
|
||||
@"Temporaries Count = %i\n"
|
||||
@"Stack Size = %i\n"
|
||||
@"Byte Codes = %@\n",
|
||||
[self clasName],
|
||||
selector,
|
||||
[literals count],
|
||||
[literals description],
|
||||
[externRefs description],
|
||||
tempCount,
|
||||
stackSize,
|
||||
[bytecodes description]];
|
||||
|
||||
return desc;
|
||||
}
|
||||
@end
|
45
Languages/Smalltalk/STCompiledScript.h
Normal file
45
Languages/Smalltalk/STCompiledScript.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
STCompiledScript.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSDictionary;
|
||||
@class NSMutableDictionary;
|
||||
@class NSString;
|
||||
@class STCompiledMethod;
|
||||
@class STEnvironment;
|
||||
|
||||
@interface STCompiledScript:NSObject
|
||||
{
|
||||
NSMutableDictionary *methodDictionary;
|
||||
int variableCount;
|
||||
}
|
||||
- initWithVariableCount:(unsigned)count;
|
||||
|
||||
- (id)executeInEnvironment:(STEnvironment *)env;
|
||||
|
||||
- (STCompiledMethod *)methodWithName:(NSString *)name;
|
||||
- (void)addMethod:(STCompiledMethod *)method;
|
||||
- (int)variableCount;
|
||||
@end
|
||||
|
153
Languages/Smalltalk/STCompiledScript.m
Normal file
153
Languages/Smalltalk/STCompiledScript.m
Normal file
|
@ -0,0 +1,153 @@
|
|||
/**
|
||||
STCompiledScript.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "STCompiledScript.h"
|
||||
|
||||
#import "STScriptObject.h"
|
||||
#import "STCompiledMethod.h"
|
||||
|
||||
#import <StepTalk/STObjCRuntime.h>
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
|
||||
@class STEnvironment;
|
||||
static SEL mainSelector;
|
||||
static SEL initializeSelector;
|
||||
static SEL finalizeSelector;
|
||||
|
||||
@implementation STCompiledScript:NSObject
|
||||
+ (void)initialize
|
||||
{
|
||||
mainSelector = STSelectorFromString(@"main");
|
||||
initializeSelector = STSelectorFromString(@"startUp");
|
||||
finalizeSelector = STSelectorFromString(@"finalize");
|
||||
}
|
||||
|
||||
- initWithVariableCount:(unsigned)count
|
||||
{
|
||||
[super init];
|
||||
|
||||
variableCount = count;
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)addMethod:(STCompiledMethod *)method
|
||||
{
|
||||
if(!methodDictionary)
|
||||
{
|
||||
methodDictionary = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
if( ! [method isKindOfClass:[STCompiledMethod class]] )
|
||||
{
|
||||
[NSException raise:STGenericException
|
||||
format:@"Invalid compiled method class '%@'",
|
||||
[method class]];
|
||||
}
|
||||
|
||||
[methodDictionary setObject:method forKey:[method selector]];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(methodDictionary);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (STCompiledMethod *)methodWithName:(NSString *)name
|
||||
{
|
||||
return [methodDictionary objectForKey:name];
|
||||
}
|
||||
|
||||
- (int)variableCount
|
||||
{
|
||||
return variableCount;
|
||||
}
|
||||
|
||||
- (id)executeInEnvironment:(STEnvironment *)env
|
||||
{
|
||||
STScriptObject *object;
|
||||
int methodCount;
|
||||
id retval = nil;
|
||||
|
||||
|
||||
object = [[STScriptObject alloc] initWithEnvironment:env
|
||||
compiledScript:self];
|
||||
|
||||
methodCount = [methodDictionary count];
|
||||
|
||||
if(methodCount == 0)
|
||||
{
|
||||
NSLog(@"Empty script executed");
|
||||
return nil;
|
||||
}
|
||||
else if(methodCount == 1)
|
||||
{
|
||||
NSString *selName = [[methodDictionary allKeys] objectAtIndex:0];
|
||||
SEL sel = STSelectorFromString(selName);
|
||||
|
||||
NSDebugLog(@"Executing single-method script. (%@)", selName);
|
||||
[object performSelector:sel];
|
||||
}
|
||||
else if(![object respondsToSelector:mainSelector])
|
||||
{
|
||||
NSLog(@"No 'main' method found");
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( [object respondsToSelector:initializeSelector] )
|
||||
{
|
||||
NSDebugLog(@"Sending 'startUp' to script object");
|
||||
[object performSelector:initializeSelector];
|
||||
}
|
||||
|
||||
if( [object respondsToSelector:mainSelector] )
|
||||
{
|
||||
retval = [object performSelector:mainSelector];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"No 'main' found in script");
|
||||
}
|
||||
|
||||
if( [object respondsToSelector:finalizeSelector] )
|
||||
{
|
||||
NSDebugLog(@"Sending 'finalize' to script object");
|
||||
[object performSelector:finalizeSelector];
|
||||
}
|
||||
}
|
||||
|
||||
RELEASE(object);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@end
|
130
Languages/Smalltalk/STCompiler.h
Normal file
130
Languages/Smalltalk/STCompiler.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
STCompiler.h
|
||||
Bytecode compiler. Generates STExecutableCode from source code.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#import <Foundation/NSRange.h>
|
||||
|
||||
@class STCompiledScript;
|
||||
@class STCompiledCode;
|
||||
@class STCompiledMethod;
|
||||
@class STEnvironment;
|
||||
@class STSourceReader;
|
||||
|
||||
@class STCExpression;
|
||||
@class STCMethod;
|
||||
@class STCPrimary;
|
||||
@class STCStatements;
|
||||
|
||||
@class STCompiler;
|
||||
|
||||
@class NSMutableData;
|
||||
@class NSMutableArray;
|
||||
|
||||
/*" Parser context information "*/
|
||||
typedef struct _STParserContext
|
||||
{
|
||||
STCompiler *compiler;
|
||||
STSourceReader *reader;
|
||||
} STParserContext;
|
||||
|
||||
|
||||
/*" Get compiler from parser context "*/
|
||||
#define STParserContextGetCompiler(context)\
|
||||
(((STParserContext *)context)->compiler)
|
||||
/*" Get source reader from parser context "*/
|
||||
#define STParserContextGetReader(context)\
|
||||
(((STParserContext *)context)->reader)
|
||||
#define STParserContextGetResult(context)\
|
||||
(((STParserContext *)context)->result)
|
||||
#define STParserContextSetResult(context, c)\
|
||||
( ASSIGN(((STParserContext *)(context))->result, (c)) )
|
||||
|
||||
/*" Initialize parser context "*/
|
||||
#define STParserContextInit(context,aCompiler,aReader) \
|
||||
do { \
|
||||
((STParserContext *)context)->compiler = aCompiler; \
|
||||
((STParserContext *)context)->reader = aReader; \
|
||||
} while(0)
|
||||
|
||||
@interface STCompiler:NSObject
|
||||
{
|
||||
STEnvironment *environment;
|
||||
|
||||
STSourceReader *reader;
|
||||
STParserContext context;
|
||||
|
||||
NSMutableData *byteCodes;
|
||||
NSMutableArray *tempVars;
|
||||
NSMutableArray *externVars;
|
||||
NSMutableArray *receiverVars;
|
||||
NSMutableArray *literals;
|
||||
|
||||
STCompiledScript *script;
|
||||
|
||||
unsigned stackSize; /* Required stack size */
|
||||
unsigned stackPos; /* Current stack pointer */
|
||||
unsigned tempsSize; /* Required temp space */
|
||||
unsigned tempsCount; /* Actual temp space */
|
||||
unsigned bcpos; /* Bytecode position */
|
||||
|
||||
Class stringLiteralClass; /* default: NSMutableString */
|
||||
Class arrayLiteralClass; /* default: NSMutableArray */
|
||||
Class characterLiteralClass; /* default: NSString */
|
||||
Class numberLiteralClass; /* default: NSNumber */
|
||||
Class symbolLiteralClass; /* default: NSString */
|
||||
}
|
||||
/*" Instance creation "*/
|
||||
+ (STCompiler *)sharedCompiler;
|
||||
|
||||
/*" Environment "*/
|
||||
- (void)setEnvironment:(STEnvironment *)env;
|
||||
- (STSourceReader *)sourceReader;
|
||||
|
||||
/*" Compilation "*/
|
||||
|
||||
- (STCompiledCode *)compileString:(NSString *)aString;
|
||||
- (STCompiledScript *)compileScript:(NSString *)script;
|
||||
|
||||
/*
|
||||
- (NSMutableArray *)compileString:(NSString *)string;
|
||||
- (NSMutableArray *)compileString:(NSString *)string range:(NSRange) range;
|
||||
*/
|
||||
|
||||
|
||||
/*" Literals "*/
|
||||
- (Class)stringLiteralClass;
|
||||
- (Class)arrayLiteralClass;
|
||||
- (Class)numberLiteralClass;
|
||||
- (Class)symbolLiteralClass;
|
||||
- (void)setStringLiteralClass:(Class)aClass;
|
||||
- (void)setArrayLiteralClass:(Class)aClass;
|
||||
- (void)setNumberLiteralClass:(Class)aClass;
|
||||
- (void)setSymbolLiteralClass:(Class)aClass;
|
||||
|
||||
- (void)setReceiverVariables:(NSArray *)vars;
|
||||
|
||||
- (void)addTempVariable:(NSString *)varName;
|
||||
@end
|
944
Languages/Smalltalk/STCompiler.m
Normal file
944
Languages/Smalltalk/STCompiler.m
Normal file
|
@ -0,0 +1,944 @@
|
|||
/**
|
||||
STCompiler.m
|
||||
Bytecode compiler. Generates STExecutableCode from source code.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import "STCompiler.h"
|
||||
|
||||
#import "STMessage.h"
|
||||
#import "STLiterals.h"
|
||||
#import "STBytecodes.h"
|
||||
#import "STCompiledScript.h"
|
||||
#import "STCompiledCode.h"
|
||||
#import "STCompiledMethod.h"
|
||||
#import "STCompilerUtils.h"
|
||||
#import "STSourceReader.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
#import <StepTalk/STObjectReference.h>
|
||||
#import <StepTalk/STSelector.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import "STGrammar.m.h"
|
||||
|
||||
extern int STCparse(void *context);
|
||||
|
||||
@interface STCompiler(STCompilerPrivate)
|
||||
- (void)compile;
|
||||
- (void)initializeContext;
|
||||
- (unsigned)tempVariableIndex:(NSString *)varName;
|
||||
- (unsigned)externalVariableIndex:(NSString *)varName;
|
||||
|
||||
- (void) initializeCompilation;
|
||||
|
||||
- (NSDictionary *)exceptionInfo;
|
||||
|
||||
- (unsigned)addSelectorLiteral:(NSString*)selector;
|
||||
- (unsigned)addLiteral:literal;
|
||||
|
||||
- (void)compileMethod:(STCMethod *)method;
|
||||
- (STCompiledCode *) compileStatements:(STCStatements *)statements;
|
||||
- (void)compileStatements:(STCStatements *)statements blockFlag:(BOOL)blockFlag;
|
||||
- (void)compilePrimary:(STCPrimary *)primary;
|
||||
- (void)compileExpression:(STCExpression *)expr;
|
||||
|
||||
- (void)emitPushReceiverVariable:(unsigned)index;
|
||||
- (void)emitPushSelf;
|
||||
- (void)emitPopAndStoreReceiverVariable:(unsigned)index;
|
||||
- (void)emitReturn;
|
||||
- (void)emitReturnFromBlock;
|
||||
- (void)emitPushTemporary:(unsigned)index;
|
||||
- (void)emitPushLiteral:(unsigned)index;
|
||||
- (void)emitPushVariable:(unsigned)index;
|
||||
- (void)emitPopAndStoreTemporary:(unsigned)index;
|
||||
- (void)emitPopAndStoreVariable:(unsigned)index ;
|
||||
- (void)emitPopStack;
|
||||
- (void)emitSendSelector:(unsigned)index argCount:(unsigned)argCount;
|
||||
- (void)emitBlockCopy;
|
||||
- (void)emitDuplicateStackTop;
|
||||
- (void)emitJump:(short)offset;
|
||||
- (void)emitLongJump:(short)offset;
|
||||
- (void)fixupLongJumpAt:(unsigned)index with:(short)offset;
|
||||
- (unsigned)currentBytecode;
|
||||
@end
|
||||
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
@implementation STCompiler
|
||||
- init
|
||||
{
|
||||
[super init];
|
||||
|
||||
arrayLiteralClass = [NSMutableArray class];
|
||||
stringLiteralClass = [NSMutableString class];
|
||||
/* bytesLiteralClass = [NSMutableData class]; */
|
||||
numberLiteralClass = [NSNumber class];
|
||||
symbolLiteralClass = [STSelector class];
|
||||
characterLiteralClass = [NSString class];
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Compilation
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (void)setEnvironment:(STEnvironment *)env
|
||||
{
|
||||
if(!reader)
|
||||
{
|
||||
reader = [[STSourceReader alloc] init];
|
||||
}
|
||||
ASSIGN(environment,env);
|
||||
}
|
||||
|
||||
|
||||
- (STCompiledScript *)compileString:(NSString *)aString
|
||||
{
|
||||
NSString *exceptionFmt = @"Syntax error at line %i near '%@', "
|
||||
@"reason: %@.";
|
||||
int parsRetval = 0;
|
||||
|
||||
|
||||
NSDebugLLog(@"STCompiler", @"Compile string", aString);
|
||||
|
||||
if(!environment)
|
||||
{
|
||||
[NSException raise:STCompilerGenericException
|
||||
format:@"Compilation environment is not initialized"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
reader = [[STSourceReader alloc] initWithString:aString];
|
||||
receiverVars = [[NSMutableArray alloc] init];
|
||||
|
||||
STParserContextInit(&context,self,reader);
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
// extern int STCdebug;
|
||||
// STCdebug = 1;
|
||||
parsRetval = STCparse(&context);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
if ([[localException name] isEqualToString: STCompilerSyntaxException])
|
||||
{
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:exceptionFmt,
|
||||
[reader currentLine],
|
||||
[reader tokenString],
|
||||
[localException reason]];
|
||||
|
||||
}
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
RELEASE(reader);
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
- (void)compileMethod:(STCMethod *)method
|
||||
{
|
||||
STCompiledMethod *compiledMethod;
|
||||
STCompiledCode *code;
|
||||
STMessage *messagePattern;
|
||||
|
||||
if(!script)
|
||||
{
|
||||
NSDebugLLog(@"STCompiler",
|
||||
@"Creating script with %i variables",[receiverVars count]);
|
||||
|
||||
script = [[STCompiledScript alloc] initWithVariableCount:
|
||||
[receiverVars count]];
|
||||
}
|
||||
|
||||
messagePattern = [method messagePattern];
|
||||
|
||||
if(!messagePattern)
|
||||
{
|
||||
messagePattern = [STMessage messageWithSelector:@"_unnamed_method"
|
||||
arguments:nil];
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STCompiler", @"Compile method %@", [messagePattern selector]);
|
||||
|
||||
tempVars = [NSMutableArray arrayWithArray:[messagePattern arguments]];
|
||||
|
||||
code = [self compileStatements:[method statements]];
|
||||
|
||||
compiledMethod = [STCompiledMethod methodWithCode:code
|
||||
messagePattern:messagePattern];
|
||||
|
||||
[script addMethod:compiledMethod];
|
||||
}
|
||||
|
||||
- (STCompiledCode *)compileStatements:(STCStatements *)statements
|
||||
{
|
||||
STCompiledCode *compiledCode;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
[self initializeCompilationContext];
|
||||
|
||||
NSDebugLLog(@"STCompiler", @"compiling statements");
|
||||
|
||||
tempsSize = tempsCount = [tempVars count];
|
||||
|
||||
[self compileStatements:statements blockFlag:NO];
|
||||
|
||||
NSDebugLLog(@"STCompiler", @" temporaries %i stack %i",
|
||||
tempsSize,stackSize);
|
||||
|
||||
#ifdef DEBUG
|
||||
count = [literals count];
|
||||
|
||||
NSDebugLLog(@"STCompiler", @" literals count %i", count);
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
NSDebugLLog(@"STCompiler",
|
||||
@" %2i %@", i, [literals objectAtIndex:i]);
|
||||
}
|
||||
|
||||
count = [externVars count];
|
||||
NSDebugLLog(@"STCompiler",@" extern vars count %i",count);
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
NSDebugLLog(@"STCompiler",
|
||||
@" %i %@",i,[externVars objectAtIndex:i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
compiledCode = [STCompiledCode alloc];
|
||||
|
||||
[compiledCode initWithBytecodesData:byteCodes
|
||||
literals:literals
|
||||
temporariesCount:tempsSize
|
||||
stackSize:stackSize
|
||||
externReferences:externVars];
|
||||
|
||||
return compiledCode;
|
||||
}
|
||||
|
||||
- (STSourceReader *)sourceReader
|
||||
{
|
||||
return reader;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variables
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (unsigned)tempVariableIndex:(NSString *)varName
|
||||
{
|
||||
return [tempVars indexOfObject:varName];
|
||||
}
|
||||
|
||||
- (void)setReceiverVariables:(NSArray *)array
|
||||
{
|
||||
ASSIGN(receiverVars,array);
|
||||
}
|
||||
|
||||
- (unsigned)receiverVariableIndex:(NSString *)varName
|
||||
{
|
||||
return [receiverVars indexOfObject:varName];
|
||||
}
|
||||
|
||||
- (void)addTempVariable:(NSString *)varName
|
||||
{
|
||||
if([tempVars containsObject:varName])
|
||||
{
|
||||
[NSException raise:STCompilerGenericException
|
||||
format:@"Multiple definition of temporary variable %@",
|
||||
varName];
|
||||
}
|
||||
else
|
||||
{
|
||||
[tempVars addObject:varName];
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned)addSelectorLiteral:(NSString*)selector
|
||||
{
|
||||
return [self addLiteral:selector];
|
||||
}
|
||||
|
||||
- (unsigned)addLiteral:literal
|
||||
{
|
||||
[literals addObject:literal];
|
||||
return [literals count] - 1;
|
||||
}
|
||||
|
||||
- (unsigned)externalVariableIndex:(NSString *)varName
|
||||
{
|
||||
STObjectReferenceLiteral *ref;
|
||||
unsigned i;
|
||||
unsigned count;
|
||||
|
||||
count = [externVars count];
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
ref = [externVars objectAtIndex:i];
|
||||
if([[ref objectName] isEqualToString:varName])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
ref = [[STObjectReferenceLiteral alloc] initWithObjectName:varName
|
||||
poolName:nil];
|
||||
[externVars addObject:ref];
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Compiler internals (called from parser)
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (void) initializeCompilationContext
|
||||
{
|
||||
byteCodes = [NSMutableData data];
|
||||
externVars = [NSMutableArray array];
|
||||
literals = [NSMutableArray array];
|
||||
|
||||
stackSize = stackPos = 0;
|
||||
tempsSize = tempsCount = 0;
|
||||
bcpos = 0;
|
||||
}
|
||||
|
||||
- (void)compileStatements:(STCStatements *)statements blockFlag:(BOOL)blockFlag
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
STBlockLiteral *blockInfo;
|
||||
STCExpression *expr;
|
||||
NSArray *array;
|
||||
unsigned tempsSave; /* stored count of temporaries */
|
||||
unsigned stackPosSave; /* stored previous stack value */
|
||||
unsigned stackSizeSave;
|
||||
unsigned jumpIP; /* location of jump bytecode for later fixup */
|
||||
unsigned index;
|
||||
unsigned argCount=0; /* argument count for block context */
|
||||
|
||||
NSDebugLLog(@"STCompiler-misc",
|
||||
@" compile statements; blockFlag=%i; tempCount=%i",
|
||||
blockFlag,tempsCount);
|
||||
|
||||
tempsSave = tempsCount; /* store value, so we can cleanup array later */
|
||||
|
||||
array = [statements temporaries];
|
||||
|
||||
NSDebugLLog(@"STCompiler-misc",@" temporaries %@", array);
|
||||
|
||||
if(array)
|
||||
{
|
||||
argCount = [array count];
|
||||
for(index=0;index<argCount;index++)
|
||||
{
|
||||
[self addTempVariable:[array objectAtIndex:index]];
|
||||
}
|
||||
|
||||
tempsCount += argCount;
|
||||
tempsSize = MAX(tempsSize,tempsCount);
|
||||
}
|
||||
|
||||
if(blockFlag)
|
||||
{
|
||||
|
||||
blockInfo = [STBlockLiteral alloc];
|
||||
[blockInfo initWithArgumentCount:argCount];
|
||||
|
||||
index = [self addLiteral:blockInfo];
|
||||
[self emitPushLiteral:index];
|
||||
[self emitBlockCopy];
|
||||
|
||||
jumpIP = [self currentBytecode];
|
||||
|
||||
/* block has its own stack */
|
||||
stackPosSave = stackPos;
|
||||
stackSizeSave = stackSize;
|
||||
stackSize = argCount;
|
||||
stackPos = argCount;
|
||||
|
||||
[self emitLongJump:0];
|
||||
|
||||
for(index = argCount; index > 0; index--)
|
||||
{
|
||||
[self emitPopAndStoreTemporary:tempsSave + index - 1];
|
||||
}
|
||||
}
|
||||
|
||||
array = [statements expressions];
|
||||
|
||||
if(array)
|
||||
{
|
||||
enumerator = [array objectEnumerator];
|
||||
while((expr = [enumerator nextObject]))
|
||||
{
|
||||
[self compileExpression:expr];
|
||||
}
|
||||
}
|
||||
|
||||
expr = [statements returnExpression];
|
||||
if(expr)
|
||||
{
|
||||
[self compileExpression:expr];
|
||||
}
|
||||
|
||||
if(blockFlag)
|
||||
{
|
||||
[blockInfo setStackSize:stackSize];
|
||||
AUTORELEASE(blockInfo);
|
||||
|
||||
stackSize = stackSizeSave;
|
||||
stackPos = stackPosSave;
|
||||
|
||||
[self emitReturnFromBlock];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self emitReturn];
|
||||
}
|
||||
|
||||
/* fixup jump (if block) */
|
||||
if(blockFlag)
|
||||
{
|
||||
[self fixupLongJumpAt:jumpIP with:[self currentBytecode] - jumpIP];
|
||||
}
|
||||
|
||||
/* cleanup unneeded temp variables */
|
||||
[tempVars removeObjectsInRange:NSMakeRange(tempsSave,
|
||||
[tempVars count]-tempsSave)];
|
||||
tempsCount = tempsSave;
|
||||
}
|
||||
|
||||
- (void)compilePrimary:(STCPrimary *)primary
|
||||
{
|
||||
id object = [primary object];
|
||||
int index;
|
||||
|
||||
NSDebugLLog(@"STCompiler-misc",@" compile primary");
|
||||
|
||||
switch([primary type])
|
||||
{
|
||||
case STCVariablePrimaryType:
|
||||
|
||||
if([object isEqualToString:@"YES"]
|
||||
|| [object isEqualToString:@"true"])
|
||||
{
|
||||
[self emitPushTrue];
|
||||
}
|
||||
else if([object isEqualToString:@"NO"]
|
||||
|| [object isEqualToString:@"false"])
|
||||
{
|
||||
[self emitPushFalse];
|
||||
}
|
||||
else if([object isEqualToString:@"nil"])
|
||||
{
|
||||
[self emitPushNil];
|
||||
}
|
||||
else
|
||||
{
|
||||
index = [self tempVariableIndex:object];
|
||||
if(index != NSNotFound)
|
||||
{
|
||||
[self emitPushTemporary:index];
|
||||
break;
|
||||
}
|
||||
else if( (index = [self receiverVariableIndex:object])!= NSNotFound)
|
||||
{
|
||||
[self emitPushReceiverVariable:index];
|
||||
break;
|
||||
}
|
||||
else if( [object isEqual:@"self"] )
|
||||
{
|
||||
[self emitPushSelf];
|
||||
break;
|
||||
}
|
||||
|
||||
index = [self externalVariableIndex:object];
|
||||
[self emitPushVariable:index];
|
||||
}
|
||||
break;
|
||||
|
||||
case STCLiteralPrimaryType:
|
||||
|
||||
index = [self addLiteral:object];
|
||||
[self emitPushLiteral:index];
|
||||
break;
|
||||
|
||||
case STCBlockPrimaryType:
|
||||
|
||||
[self compileStatements:object blockFlag:YES];
|
||||
break;
|
||||
|
||||
case STCExpressionPrimaryType:
|
||||
|
||||
[self compileExpression:object];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
[NSException raise:STCompilerInconsistencyException
|
||||
format:@"Unknown primary type %i",
|
||||
[primary type]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)compileMessage:(STCMessage *)message
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSArray *args;
|
||||
id obj;
|
||||
int index;
|
||||
|
||||
args = [message arguments];
|
||||
if(args && ([args count]>0))
|
||||
{
|
||||
enumerator = [args objectEnumerator];
|
||||
while((obj = [enumerator nextObject]))
|
||||
{
|
||||
if([obj isKindOfClass:[STCPrimary class]])
|
||||
[self compilePrimary:obj];
|
||||
else
|
||||
[self compileExpression:obj];
|
||||
}
|
||||
}
|
||||
|
||||
index = [self addSelectorLiteral:[message selector]];
|
||||
[self emitSendSelector:index argCount:[args count]];
|
||||
}
|
||||
|
||||
- (void)compileExpression:(STCExpression *)expr
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSArray *cascade;
|
||||
NSString *varName;
|
||||
NSArray *array;
|
||||
unsigned count;
|
||||
unsigned index,i;
|
||||
id obj;
|
||||
|
||||
NSDebugLLog(@"STCompiler-misc",@" compile expression");
|
||||
|
||||
if([expr isPrimary])
|
||||
{
|
||||
[self compilePrimary:[expr object]];
|
||||
}
|
||||
else /* message expression */
|
||||
{
|
||||
obj = [expr target];
|
||||
|
||||
/* target */
|
||||
if([obj isKindOfClass:[STCPrimary class]])
|
||||
[self compilePrimary:obj];
|
||||
else
|
||||
[self compileExpression:obj];
|
||||
|
||||
cascade = [expr cascade];
|
||||
if(cascade)
|
||||
{
|
||||
count = [cascade count];
|
||||
for(i=0;i<count;i++)
|
||||
[self emitDuplicateStackTop];
|
||||
}
|
||||
|
||||
[self compileMessage:[expr message]];
|
||||
|
||||
/* cascade expression */
|
||||
if(cascade)
|
||||
{
|
||||
enumerator = [cascade objectEnumerator];
|
||||
while( (obj = [enumerator nextObject]) )
|
||||
{
|
||||
/* ignore previous return value */
|
||||
[self emitPopStack];
|
||||
[self compileMessage:obj];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
array = [expr assignments];
|
||||
count = [array count];
|
||||
if(array && count>0)
|
||||
{
|
||||
for(i = 0; i<count; i++)
|
||||
{
|
||||
[self emitDuplicateStackTop];
|
||||
}
|
||||
|
||||
for(i = 0; i<count; i++)
|
||||
{
|
||||
varName = [array objectAtIndex:i];
|
||||
|
||||
index = [self tempVariableIndex:varName];
|
||||
if(index != NSNotFound)
|
||||
{
|
||||
[self emitPopAndStoreTemporary:index];
|
||||
continue;
|
||||
}
|
||||
else if( (index = [self receiverVariableIndex:varName])!= NSNotFound)
|
||||
{
|
||||
[self emitPopAndStoreReceiverVariable:index];
|
||||
continue;
|
||||
}
|
||||
if( [varName isEqual:@"self"] )
|
||||
{
|
||||
NSLog(@"Warning: trying to store to self (ignoring)");
|
||||
[self emitPopStack];
|
||||
continue;
|
||||
}
|
||||
|
||||
index = [self externalVariableIndex:varName];
|
||||
[self emitPopAndStoreVariable:index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Literal classes
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
- (Class)stringLiteralClass
|
||||
{
|
||||
return stringLiteralClass;
|
||||
}
|
||||
- (Class)arrayLiteralClass
|
||||
{
|
||||
return arrayLiteralClass;
|
||||
}
|
||||
- (Class)numberLiteralClass
|
||||
{
|
||||
return numberLiteralClass;
|
||||
}
|
||||
- (Class)symbolLiteralClass
|
||||
{
|
||||
return symbolLiteralClass;
|
||||
}
|
||||
- (Class)characterLiteralClass
|
||||
{
|
||||
return characterLiteralClass;
|
||||
}
|
||||
- (void)setStringLiteralClass:(Class)aClass
|
||||
{
|
||||
stringLiteralClass = aClass;
|
||||
}
|
||||
- (void)setArrayLiteralClass:(Class)aClass
|
||||
{
|
||||
arrayLiteralClass = aClass;
|
||||
}
|
||||
- (void)setNumberLiteralClass:(Class)aClass
|
||||
{
|
||||
numberLiteralClass = aClass;
|
||||
}
|
||||
- (void)setSymbolLiteralClass:(Class)aClass
|
||||
{
|
||||
symbolLiteralClass = aClass;
|
||||
}
|
||||
- (void)setCharacterLiteralClass:(Class)aClass
|
||||
{
|
||||
characterLiteralClass = aClass;
|
||||
}
|
||||
|
||||
- (id)createNumberLiteralFrom:(NSString *)aString
|
||||
{
|
||||
return [numberLiteralClass numberFromString:aString];
|
||||
}
|
||||
- (id)createSymbolLiteralFrom:(NSString *)aString
|
||||
{
|
||||
return [symbolLiteralClass symbolFromString:aString];
|
||||
}
|
||||
- (id)createStringLiteralFrom:(NSString *)aString
|
||||
{
|
||||
return [stringLiteralClass stringFromString:aString];
|
||||
}
|
||||
- (id)createCharacterLiteralFrom:(NSString *)aString
|
||||
{
|
||||
return [characterLiteralClass characterFromString:aString];
|
||||
}
|
||||
- (id)createArrayLiteralFrom:(NSArray *)anArray
|
||||
{
|
||||
return [arrayLiteralClass arrayFromArray:anArray];
|
||||
}
|
||||
|
||||
- (NSDictionary *)exceptionInfo
|
||||
{
|
||||
NSDictionary *dict;
|
||||
|
||||
dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[reader currentLine],
|
||||
@"LineNumber",
|
||||
[reader tokenString],
|
||||
@"Token",
|
||||
[NSValue valueWithRange:[reader tokenRange]],
|
||||
@"TokenRange",
|
||||
nil,nil];
|
||||
return nil;
|
||||
}
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Emit bytecodes
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define STDebugEmit(bc) \
|
||||
NSDebugLLog(@"STCompiler-emit", \
|
||||
@"#%04x %@", \
|
||||
(bc).pointer, \
|
||||
STDissasembleBytecode(bc))
|
||||
|
||||
#define STDebugEmitWith(bc,object) \
|
||||
NSDebugLLog(@"STCompiler-emit", \
|
||||
@"#%04x %@ (%@)", \
|
||||
(bc).pointer, \
|
||||
STDissasembleBytecode(bc), \
|
||||
(object))
|
||||
|
||||
#define EMIT_SINGLE(bytecode) \
|
||||
do { \
|
||||
char bc = bytecode; \
|
||||
[byteCodes appendBytes:&bc length:1];\
|
||||
bcpos++;\
|
||||
} while(0)
|
||||
#define EMIT_DOUBLE(bc1,bc2) \
|
||||
do { \
|
||||
char bc[2] = {bc1,bc2}; \
|
||||
[byteCodes appendBytes:bc length:2];\
|
||||
bcpos+=2;\
|
||||
} while(0)
|
||||
#define EMIT_TRIPPLE(bc1,bc2,bc3) \
|
||||
do { \
|
||||
char bc[3] = {bc1,bc2,bc3}; \
|
||||
[byteCodes appendBytes:bc length:3];\
|
||||
bcpos+=3;\
|
||||
} while(0)
|
||||
|
||||
#define STACK_PUSH \
|
||||
do {\
|
||||
stackPos++; \
|
||||
stackSize = MAX(stackPos,stackSize);\
|
||||
/* NSDebugLLog(@"STCompiler",@"stack pointer %i/%i",stackPos,stackSize); */\
|
||||
} while(0)
|
||||
#define STACK_PUSH_COUNT(count) \
|
||||
do {\
|
||||
stackPos+=count; \
|
||||
stackSize = MAX(stackPos,stackSize);\
|
||||
/* NSDebugLLog(@"STCompiler",@"stack pointer %i/%i",stackPos,stackSize);*/ \
|
||||
} while(0)
|
||||
|
||||
#define STACK_POP \
|
||||
stackPos--; \
|
||||
/* NSDebugLLog(@"STCompiler",@"stack pointer %i/%i",stackPos,stackSize) */;
|
||||
#define STACK_POP_COUNT(count) \
|
||||
stackPos-=count; \
|
||||
/* NSDebugLLog(@"STCompiler",@"stack pointer %i/%i",stackPos,stackSize) */;
|
||||
|
||||
- (void)emitPushSelf
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push self", bcpos);
|
||||
|
||||
EMIT_SINGLE(STPushReceiverBytecode);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPushNil
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push nil", bcpos);
|
||||
|
||||
EMIT_SINGLE(STPushNilBytecode);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPushTrue
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push true", bcpos);
|
||||
|
||||
EMIT_SINGLE(STPushTrueBytecode);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPushFalse
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push false", bcpos);
|
||||
|
||||
EMIT_SINGLE(STPushFalseBytecode);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPushReceiverVariable:(unsigned)index
|
||||
{
|
||||
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push receiver variable %i (%@)",
|
||||
bcpos,index,[receiverVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPushRecVarBytecode,index);
|
||||
STACK_PUSH;
|
||||
}
|
||||
|
||||
- (void)emitPushTemporary:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push temporary %i (%@)",
|
||||
bcpos,index,[tempVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPushTemporaryBytecode,index);
|
||||
STACK_PUSH;
|
||||
|
||||
}
|
||||
|
||||
- (void)emitPushLiteral:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push literal %i (%@)",
|
||||
bcpos,index,[literals objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPushLiteralBytecode,index);
|
||||
STACK_PUSH;
|
||||
stackSize++;
|
||||
}
|
||||
- (void)emitPushVariable:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x push external variable %i (%@)",
|
||||
bcpos,index,[externVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPushExternBytecode,index);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPopAndStoreTemporary:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x pop and store temp %i (%@)",
|
||||
bcpos,index,[tempVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPopAndStoreTempBytecode,index);
|
||||
STACK_POP;
|
||||
}
|
||||
- (void)emitPopAndStoreVariable:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x pop and store ext variable %i (%@)",
|
||||
bcpos,index,[externVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPopAndStoreExternBytecode,index);
|
||||
STACK_POP;
|
||||
}
|
||||
- (void)emitPopAndStoreReceiverVariable:(unsigned)index
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x pop and store rec variable %i (%@)",
|
||||
bcpos,index,[receiverVars objectAtIndex:index]);
|
||||
|
||||
EMIT_DOUBLE(STPopAndStoreRecVarBytecode,index);
|
||||
STACK_POP;
|
||||
}
|
||||
|
||||
- (void)emitSendSelector:(unsigned)index argCount:(unsigned)argCount
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x send selector %i (%@) with %i args",
|
||||
bcpos,index,[literals objectAtIndex:index],argCount);
|
||||
|
||||
EMIT_TRIPPLE(STSendSelectorBytecode,index,argCount);
|
||||
STACK_PUSH_COUNT(argCount);
|
||||
STACK_POP_COUNT(argCount);
|
||||
}
|
||||
- (void)emitDuplicateStackTop
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x dup",bcpos);
|
||||
|
||||
EMIT_SINGLE(STDupBytecode);
|
||||
STACK_PUSH;
|
||||
}
|
||||
- (void)emitPopStack
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x pop stack",bcpos);
|
||||
|
||||
EMIT_SINGLE(STPopStackBytecode);
|
||||
STACK_POP;
|
||||
}
|
||||
- (void)emitReturn
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x return",bcpos);
|
||||
|
||||
EMIT_SINGLE(STReturnBytecode);
|
||||
}
|
||||
- (void)emitReturnFromBlock
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x return from block",bcpos);
|
||||
|
||||
EMIT_SINGLE(STReturnBlockBytecode);
|
||||
}
|
||||
- (void)emitBlockCopy
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x create block",bcpos);
|
||||
|
||||
EMIT_SINGLE(STBlockCopyBytecode);
|
||||
}
|
||||
- (void)emitLongJump:(short)offset
|
||||
{
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"#%04x long jump %i (0x%04x)",bcpos,offset,bcpos+offset);
|
||||
|
||||
EMIT_TRIPPLE(STLongJumpBytecode,STLongJumpFirstByte(offset),
|
||||
STLongJumpSecondByte(offset));
|
||||
}
|
||||
- (void)fixupLongJumpAt:(unsigned)index with:(short)offset
|
||||
{
|
||||
char bytes[2] = {STLongJumpFirstByte(offset),STLongJumpSecondByte(offset)};
|
||||
|
||||
NSDebugLLog(@"STCompiler-emit",
|
||||
@"# fixup long jump at 0x%04x to 0x%04x",index, index + offset);
|
||||
|
||||
[byteCodes replaceBytesInRange:NSMakeRange(index+1,2) withBytes:bytes];
|
||||
|
||||
}
|
||||
- (unsigned)currentBytecode
|
||||
{
|
||||
return [byteCodes length];
|
||||
}
|
||||
|
||||
@end
|
184
Languages/Smalltalk/STCompilerUtils.h
Normal file
184
Languages/Smalltalk/STCompilerUtils.h
Normal file
|
@ -0,0 +1,184 @@
|
|||
/**
|
||||
STCompilerUtils.h
|
||||
Various compiler utilities.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of StepTalk.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
@class STCMessage;
|
||||
@class STCStatements;
|
||||
@class STCExpression;
|
||||
|
||||
enum{
|
||||
STCVariablePrimaryType,
|
||||
STCLiteralPrimaryType,
|
||||
STCBlockPrimaryType,
|
||||
STCExpressionPrimaryType
|
||||
};
|
||||
|
||||
@interface STCompiler(Utils_private)
|
||||
- (STCompiledMethod *)compileMethod:(STCMethod *)method;
|
||||
- (id)createNumberLiteralFrom:(NSString *)aString;
|
||||
- (id)createSymbolLiteralFrom:(NSString *)aString;
|
||||
- (id)createStringLiteralFrom:(NSString *)aString;
|
||||
- (id)createCharacterLiteralFrom:(NSString *)aString;
|
||||
- (id)createArrayLiteralFrom:(NSArray *)anArray;
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCMethod
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@interface STCMethod:NSObject
|
||||
{
|
||||
STCMessage *messagePattern;
|
||||
STCStatements *statements;
|
||||
}
|
||||
+ methodWithPattern:(STCMessage *)patt statements:(STCStatements *)stats;
|
||||
- initWithPattern:(STCMessage *)patt statements:(STCStatements *)stats;
|
||||
- (STCStatements *)statements;
|
||||
- (STCMessage *)messagePattern;
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCStatements
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@interface STCStatements:NSObject
|
||||
{
|
||||
NSArray *variables;
|
||||
NSArray *expressions;
|
||||
STCExpression *retexpr;
|
||||
}
|
||||
+ statements;
|
||||
|
||||
- (void)setTemporaries:(NSArray *)vars;
|
||||
- (NSArray *)temporaries;
|
||||
|
||||
- (void)setExpressions:(NSArray *)exprs;
|
||||
- (NSArray *)expressions;
|
||||
|
||||
- (void)setReturnExpression:(STCExpression *)ret;
|
||||
- (STCExpression *)returnExpression;
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* STCMessage
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@interface STCMessage:NSObject
|
||||
{
|
||||
NSMutableString *selector;
|
||||
NSMutableArray *args;
|
||||
}
|
||||
+ message;
|
||||
- (void) addKeyword:(NSString *)keyword object:object;
|
||||
- (NSString *)selector;
|
||||
- (NSArray*)args;
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* STCExpression
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@interface STCExpression:NSObject
|
||||
{
|
||||
NSArray *cascade;
|
||||
NSArray *assignments;
|
||||
}
|
||||
+ (STCExpression *) primaryExpressionWithObject:(id)anObject;
|
||||
+ (STCExpression *) messageExpressionWithTarget:(id)anObject
|
||||
message:(STCMessage *)message;
|
||||
- (void)setCascade:(NSArray *)casc;
|
||||
- (void)setAssignments:(NSArray *)asgs;
|
||||
|
||||
- (NSArray *)cascade;
|
||||
- (NSArray *)assignments;
|
||||
- (BOOL) isPrimary;
|
||||
|
||||
- (id) target;
|
||||
- (STCMessage *)message;
|
||||
- (id) object;
|
||||
@end
|
||||
|
||||
@interface STCMessageExpression:STCExpression
|
||||
{
|
||||
id target;
|
||||
STCMessage *message;
|
||||
}
|
||||
- initWithTarget:(id)anObject message:(STCMessage *)message;
|
||||
@end
|
||||
|
||||
@interface STCPrimaryExpression:STCExpression
|
||||
{
|
||||
id object;
|
||||
}
|
||||
- initWithObject:(id)anObject;
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCPrimary
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@interface STCPrimary:NSObject
|
||||
{
|
||||
int type;
|
||||
id object;
|
||||
}
|
||||
+ primaryWithVariable:(id)anObject;
|
||||
+ primaryWithLiteral:(id)anObject;
|
||||
+ primaryWithBlock:(id)anObject;
|
||||
+ primaryWithExpression:(id)anObject;
|
||||
- initWithType:(int)newType object:(id)obj;
|
||||
- (int)type;
|
||||
- object;
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* Compiler additions for literals
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@interface NSString(STCompilerAdditions)
|
||||
+ (NSString *) symbolFromString:(NSString *)aString;
|
||||
+ (id) characterFromString:(NSString *)aString;
|
||||
@end
|
||||
|
||||
@interface NSMutableString(STCompilerAdditions)
|
||||
+ (id) stringFromString:(NSString *)aString;
|
||||
@end
|
||||
|
||||
@interface NSNumber(STCompilerAdditions)
|
||||
+ (id) numberFromString:(NSString *)aString;
|
||||
@end
|
||||
|
||||
@interface NSMutableArray(STCompilerAdditions)
|
||||
+ (id) arrayFromArray:(NSArray *)anArray;
|
||||
@end
|
366
Languages/Smalltalk/STCompilerUtils.m
Normal file
366
Languages/Smalltalk/STCompilerUtils.m
Normal file
|
@ -0,0 +1,366 @@
|
|||
/**
|
||||
STCompilerUtils.m
|
||||
Various compiler utilities.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of StepTalk.
|
||||
|
||||
*/
|
||||
|
||||
#import "STCompiler.h"
|
||||
|
||||
#import "STCompilerUtils.h"
|
||||
#import "STGrammar.m.h"
|
||||
#import "STSourceReader.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
/*
|
||||
* Compiler utilities
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* STCMethod
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@implementation STCMethod
|
||||
+ methodWithPattern:(STCMessage *)patt statements:(STCStatements *)stats
|
||||
{
|
||||
STCMethod *method;
|
||||
method = [[STCMethod alloc] initWithPattern:patt statements:stats];
|
||||
return AUTORELEASE(method);
|
||||
}
|
||||
- initWithPattern:(STCMessage *)patt statements:(STCStatements *)stats
|
||||
{
|
||||
[super init];
|
||||
messagePattern = RETAIN(patt);
|
||||
statements = RETAIN(stats);
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(messagePattern);
|
||||
RELEASE(statements);
|
||||
[super dealloc];
|
||||
}
|
||||
- (STCStatements *)statements
|
||||
{
|
||||
return statements;
|
||||
}
|
||||
|
||||
- (STCMessage *)messagePattern
|
||||
{
|
||||
return messagePattern;
|
||||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCStatements
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@implementation STCStatements
|
||||
+ statements
|
||||
{
|
||||
STCStatements *statements = [[STCStatements alloc] init];
|
||||
return AUTORELEASE(statements);
|
||||
}
|
||||
- (void)setTemporaries:(NSArray *)vars
|
||||
{
|
||||
ASSIGN(variables,vars);
|
||||
}
|
||||
- (void)setExpressions:(NSArray *)exprs
|
||||
{
|
||||
ASSIGN(expressions,exprs);
|
||||
}
|
||||
- (void)setReturnExpression:(STCExpression *)ret
|
||||
{
|
||||
ASSIGN(retexpr,ret);
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(variables);
|
||||
RELEASE(expressions);
|
||||
RELEASE(retexpr);
|
||||
[super dealloc];
|
||||
}
|
||||
- (NSArray *)temporaries
|
||||
{
|
||||
return variables;
|
||||
}
|
||||
- (NSArray *)expressions
|
||||
{
|
||||
return expressions;
|
||||
}
|
||||
- (STCExpression *)returnExpression
|
||||
{
|
||||
return retexpr;
|
||||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCMessage
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@implementation STCMessage
|
||||
+ message
|
||||
{
|
||||
STCMessage *message = [[STCMessage alloc] init];
|
||||
return AUTORELEASE(message);
|
||||
}
|
||||
- init
|
||||
{
|
||||
[super init];
|
||||
|
||||
selector = [[NSMutableString alloc] init];
|
||||
args = [[NSMutableArray alloc] init];
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(selector);
|
||||
RELEASE(args);
|
||||
[super dealloc];
|
||||
}
|
||||
-(void) addKeyword:(NSString *)keyword object:object
|
||||
{
|
||||
[selector appendString:keyword];
|
||||
if(object!=nil)
|
||||
[args addObject:object];
|
||||
}
|
||||
- (NSString *)selector
|
||||
{
|
||||
return selector;
|
||||
}
|
||||
- (NSArray *)arguments
|
||||
{
|
||||
return args;
|
||||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCExpression
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@implementation STCExpression:NSObject
|
||||
+ (STCExpression *) primaryExpressionWithObject:(id)anObject
|
||||
{
|
||||
STCPrimaryExpression *expr;
|
||||
expr = [[STCPrimaryExpression alloc] initWithObject:anObject];
|
||||
return AUTORELEASE(expr);
|
||||
}
|
||||
|
||||
+ (STCExpression *) messageExpressionWithTarget:(id)anObject
|
||||
message:(STCMessage *)message
|
||||
{
|
||||
STCMessageExpression *expr;
|
||||
expr = [[STCMessageExpression alloc] initWithTarget:anObject
|
||||
message:message];
|
||||
return AUTORELEASE(expr);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(cascade);
|
||||
RELEASE(assignments);
|
||||
[super dealloc];
|
||||
}
|
||||
- (void)setCascade:(NSArray *)casc
|
||||
{
|
||||
ASSIGN(cascade,casc);
|
||||
}
|
||||
- (void)setAssignments:(NSArray *)asgs
|
||||
{
|
||||
ASSIGN(assignments,asgs);
|
||||
}
|
||||
- (NSArray *)cascade
|
||||
{
|
||||
return cascade;
|
||||
}
|
||||
- (NSArray *)assignments
|
||||
{
|
||||
return assignments;
|
||||
}
|
||||
- (BOOL)isPrimary
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return NO;
|
||||
}
|
||||
- (id) target
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (STCMessage *)message
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (id) object
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation STCMessageExpression:STCExpression
|
||||
- initWithTarget:(id)anObject message:(STCMessage *)aMessage;
|
||||
{
|
||||
[super init];
|
||||
|
||||
target = RETAIN(anObject);
|
||||
message = RETAIN(aMessage);
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(target);
|
||||
RELEASE(message);
|
||||
[super dealloc];
|
||||
}
|
||||
- (id) target
|
||||
{
|
||||
return target;
|
||||
}
|
||||
- (STCMessage *)message
|
||||
{
|
||||
return message;
|
||||
}
|
||||
- (BOOL)isPrimary
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation STCPrimaryExpression:STCExpression
|
||||
{
|
||||
id object;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(object);
|
||||
[super dealloc];
|
||||
}
|
||||
- initWithObject:(id)anObject
|
||||
{
|
||||
[super init];
|
||||
object = RETAIN(anObject);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) object
|
||||
{
|
||||
return object;
|
||||
}
|
||||
- (BOOL)isPrimary
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* STCPrimary
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
@implementation STCPrimary
|
||||
+ primaryWithVariable:(id) anObject
|
||||
{
|
||||
STCPrimary *primary;
|
||||
primary = [STCPrimary alloc];
|
||||
[primary initWithType:STCVariablePrimaryType object:anObject];
|
||||
return AUTORELEASE(primary);
|
||||
}
|
||||
+ primaryWithLiteral:(id) anObject
|
||||
{
|
||||
STCPrimary *primary;
|
||||
primary = [STCPrimary alloc];
|
||||
[primary initWithType:STCLiteralPrimaryType object:anObject];
|
||||
return AUTORELEASE(primary);
|
||||
}
|
||||
+ primaryWithBlock:(id) anObject
|
||||
{
|
||||
STCPrimary *primary;
|
||||
primary = [STCPrimary alloc];
|
||||
[primary initWithType:STCBlockPrimaryType object:anObject];
|
||||
return AUTORELEASE(primary);
|
||||
}
|
||||
+ primaryWithExpression:(id) anObject
|
||||
{
|
||||
STCPrimary *primary;
|
||||
primary = [STCPrimary alloc];
|
||||
[primary initWithType:STCExpressionPrimaryType object:anObject];
|
||||
return AUTORELEASE(primary);
|
||||
}
|
||||
- initWithType:(int)newType object:obj
|
||||
{
|
||||
type = newType;
|
||||
object = RETAIN(obj);
|
||||
return [super init];
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(object);
|
||||
[super dealloc];
|
||||
}
|
||||
- (int)type
|
||||
{
|
||||
return type;
|
||||
}
|
||||
- object
|
||||
{
|
||||
return object;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* Compiler additions for literals
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@implementation NSString(STCompilerAdditions)
|
||||
+ (NSString *) symbolFromString:(NSString *)aString
|
||||
{
|
||||
return [self stringWithString:aString];
|
||||
}
|
||||
+ (id) characterFromString:(NSString *)aString
|
||||
{
|
||||
return [self stringWithString:aString];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSMutableString(STCompilerAdditions)
|
||||
+ (id) stringFromString:(NSString *)aString
|
||||
{
|
||||
return [self stringWithString:aString];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSNumber(STCompilerAdditions)
|
||||
+ (id) numberFromString:(NSString *)aString
|
||||
{
|
||||
/* FIXME: handle all formats */
|
||||
return [self numberWithInt:[aString intValue]];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSMutableArray(STCompilerAdditions)
|
||||
+ (id) arrayFromArray:(NSArray *)anArray
|
||||
{
|
||||
return [self arrayWithArray:anArray];
|
||||
}
|
||||
@end
|
64
Languages/Smalltalk/STExecutionContext.h
Normal file
64
Languages/Smalltalk/STExecutionContext.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
STExecutionContext.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class STStack;
|
||||
@class STBytecodes;
|
||||
@class STMethodContext;
|
||||
|
||||
@interface STExecutionContext:NSObject
|
||||
{
|
||||
unsigned contextId; /* for debugging */
|
||||
|
||||
STExecutionContext *parrentContext; /* for return */
|
||||
STStack *stack;
|
||||
|
||||
unsigned instructionPointer;
|
||||
}
|
||||
- initWithStackSize:(unsigned)stackSize;
|
||||
|
||||
- (void)invalidate;
|
||||
- (BOOL)isInvalid;
|
||||
|
||||
- (STExecutionContext *)parrentContext;
|
||||
- (void)setParrentContext:(STExecutionContext *)context;
|
||||
|
||||
- (STMethodContext *)homeContext;
|
||||
- (void)setHomeContext:(STMethodContext *)context;
|
||||
|
||||
- (BOOL)isBlockContext;
|
||||
|
||||
- (unsigned)instructionPointer;
|
||||
- (void)setInstructionPointer:(unsigned)value;
|
||||
|
||||
- (STBytecodes *)bytecodes;
|
||||
|
||||
- (STStack *)stack;
|
||||
|
||||
- (id)temporaryAtIndex:(unsigned)index;
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index;
|
||||
- (id)externAtIndex:(unsigned)index;
|
||||
- (void)setExtern:anObject atIndex:(unsigned)index;
|
||||
- (id)literalObjectAtIndex:(unsigned)index;
|
||||
@end
|
124
Languages/Smalltalk/STExecutionContext.m
Normal file
124
Languages/Smalltalk/STExecutionContext.m
Normal file
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
STExecutionContext.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
|
||||
#import "STExecutionContext.h"
|
||||
|
||||
#import "STStack.h"
|
||||
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
static unsigned nextId = 1;
|
||||
|
||||
@implementation STExecutionContext
|
||||
- initWithStackSize:(unsigned)stackSize
|
||||
{
|
||||
stack = [[STStack alloc] initWithSize:stackSize];
|
||||
|
||||
contextId = nextId ++;
|
||||
|
||||
return [super init];
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(stack);
|
||||
RELEASE(parrentContext);
|
||||
[super dealloc];
|
||||
}
|
||||
- (unsigned)contextId
|
||||
{
|
||||
return contextId;
|
||||
}
|
||||
- (NSString *)description
|
||||
{
|
||||
NSMutableString *str;
|
||||
str = [NSMutableString stringWithFormat:
|
||||
@"%s[%i]{p:%i h:%i}",
|
||||
[self name],
|
||||
contextId,
|
||||
[parrentContext contextId],
|
||||
[[self homeContext] contextId]];
|
||||
return str;
|
||||
}
|
||||
- (void)invalidate
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
}
|
||||
|
||||
- (BOOL)isInvalid
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (STExecutionContext *)parrentContext
|
||||
{
|
||||
return parrentContext;
|
||||
}
|
||||
- (void)setParrentContext:(STExecutionContext *)context
|
||||
{
|
||||
ASSIGN(parrentContext,context);
|
||||
}
|
||||
- (unsigned)instructionPointer
|
||||
{
|
||||
return instructionPointer;
|
||||
}
|
||||
- (void)setInstructionPointer:(unsigned)value
|
||||
{
|
||||
instructionPointer = value;
|
||||
}
|
||||
- (STMethodContext *)homeContext
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (void)setHomeContext:(STMethodContext *)newContext
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
}
|
||||
|
||||
- (STStack *)stack
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
- (BOOL)isBlockContext;
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return NO;
|
||||
}
|
||||
- (id)temporaryAtIndex:(unsigned)index
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
}
|
||||
- (id)externAtIndex:(unsigned)index
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (void)setExtern:anObject atIndex:(unsigned)index
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
}
|
||||
- (STBytecodes *)bytecodes
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
- (id)literalObjectAtIndex:(unsigned)index
|
||||
{
|
||||
[self subclassResponsibility];
|
||||
return nil;
|
||||
}
|
||||
@end
|
1437
Languages/Smalltalk/STGrammar.m
Normal file
1437
Languages/Smalltalk/STGrammar.m
Normal file
File diff suppressed because it is too large
Load diff
23
Languages/Smalltalk/STGrammar.m.h
Normal file
23
Languages/Smalltalk/STGrammar.m.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef YYSTYPE
|
||||
#define YYSTYPE int
|
||||
#endif
|
||||
#define TK_SEPARATOR 258
|
||||
#define TK_BAR 259
|
||||
#define TK_ASSIGNMENT 260
|
||||
#define TK_LPAREN 261
|
||||
#define TK_RPAREN 262
|
||||
#define TK_BLOCK_OPEN 263
|
||||
#define TK_BLOCK_CLOSE 264
|
||||
#define TK_ARRAY_OPEN 265
|
||||
#define TK_DOT 266
|
||||
#define TK_COLON 267
|
||||
#define TK_SEMICOLON 268
|
||||
#define TK_RETURN 269
|
||||
#define TK_IDENTIFIER 270
|
||||
#define TK_BINARY_SELECTOR 271
|
||||
#define TK_KEYWORD 272
|
||||
#define TK_NUMBER 273
|
||||
#define TK_SYMBOL 274
|
||||
#define TK_STRING 275
|
||||
#define TK_CHARACTER 276
|
||||
|
453
Languages/Smalltalk/STGrammar.y
Normal file
453
Languages/Smalltalk/STGrammar.y
Normal file
|
@ -0,0 +1,453 @@
|
|||
/**
|
||||
* STGrammar.y
|
||||
* StepTalk grammar
|
||||
*
|
||||
* Copyright (c) 2000 Stefan Urbanek
|
||||
*
|
||||
* This file is part of the StepTalk project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
%{
|
||||
|
||||
#define YYSTYPE id
|
||||
#define YYLTYPE int
|
||||
#undef YYDEBUG
|
||||
|
||||
#import <Foundation/NSException.h>
|
||||
#import "STCompiler.h"
|
||||
#import "STCompilerUtils.h"
|
||||
#import "STSourceReader.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
|
||||
/* extern int STCerror(const char *str);
|
||||
extern int STClex (YYSTYPE *lvalp, void *context);
|
||||
*/
|
||||
#define YYPARSE_PARAM context
|
||||
#define YYLEX_PARAM context
|
||||
#define YYERROR_VERBOSE
|
||||
|
||||
#define CONTEXT ((STParserContext *)context)
|
||||
#define COMPILER (CONTEXT->compiler)
|
||||
#define READER (CONTEXT->reader)
|
||||
#define RESULT (CONTEXT->result)
|
||||
|
||||
%}
|
||||
|
||||
%pure_parser
|
||||
|
||||
/* BISON declarations */
|
||||
|
||||
%token TK_SEPARATOR TK_BAR TK_ASSIGNMENT
|
||||
%token TK_LPAREN TK_RPAREN TK_BLOCK_OPEN TK_BLOCK_CLOSE TK_ARRAY_OPEN
|
||||
%token TK_DOT TK_COLON TK_SEMICOLON TK_RETURN
|
||||
%token TK_IDENTIFIER TK_BINARY_SELECTOR TK_KEYWORD
|
||||
%token TK_NUMBER TK_SYMBOL TK_STRING TK_CHARACTER
|
||||
|
||||
/* Grammar */
|
||||
|
||||
%%
|
||||
source: /* empty string */ {
|
||||
[COMPILER compileMethod:nil];
|
||||
}
|
||||
|
||||
|
||||
| single_method {
|
||||
[COMPILER compileMethod:$1];
|
||||
}
|
||||
|
||||
|
|
||||
TK_BLOCK_OPEN TK_BAR
|
||||
methods
|
||||
TK_BLOCK_CLOSE
|
||||
;
|
||||
|
||||
single_method: statements
|
||||
{
|
||||
$$ = [STCMethod methodWithPattern:nil
|
||||
/**/ statements:$1];
|
||||
}
|
||||
| temporaries statements
|
||||
{
|
||||
[$2 setTemporaries:$1];
|
||||
$$ = [STCMethod methodWithPattern:nil
|
||||
/**/ statements:$2];
|
||||
}
|
||||
;
|
||||
|
||||
methods:
|
||||
block_var_list
|
||||
{
|
||||
[COMPILER setReceiverVariables:$1];
|
||||
}
|
||||
method_list
|
||||
|
||||
| method_list
|
||||
;
|
||||
|
||||
method_list: method
|
||||
{
|
||||
[COMPILER compileMethod:$1];
|
||||
}
|
||||
| method_list TK_SEPARATOR method
|
||||
{
|
||||
[COMPILER compileMethod:$3];
|
||||
}
|
||||
;
|
||||
|
||||
method: message_pattern statements
|
||||
{
|
||||
$$ = [STCMethod methodWithPattern:$1
|
||||
/**/ statements:$2];
|
||||
}
|
||||
| message_pattern temporaries statements
|
||||
{
|
||||
[$3 setTemporaries:$2];
|
||||
$$ = [STCMethod methodWithPattern:$1
|
||||
/**/ statements:$3];
|
||||
}
|
||||
;
|
||||
|
||||
message_pattern:
|
||||
unary_selector
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:nil];
|
||||
}
|
||||
| binary_selector variable_name
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:$2];
|
||||
}
|
||||
| keyword_list
|
||||
;
|
||||
|
||||
keyword_list: keyword variable_name
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:$2];
|
||||
}
|
||||
| keyword_list keyword variable_name
|
||||
{
|
||||
[$1 addKeyword:$2 object:$3];
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
temporaries: TK_BAR variable_list TK_BAR
|
||||
{ $$ = $2; }
|
||||
;
|
||||
|
||||
variable_list: variable_name
|
||||
{
|
||||
$$ = [NSMutableArray array];
|
||||
[$$ addObject:$1];
|
||||
}
|
||||
| variable_list variable_name
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addObject:$2];
|
||||
}
|
||||
;
|
||||
|
||||
block: TK_BLOCK_OPEN TK_BLOCK_CLOSE
|
||||
{
|
||||
$$ = [STCStatements statements];
|
||||
}
|
||||
| TK_BLOCK_OPEN statements TK_BLOCK_CLOSE
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| TK_BLOCK_OPEN block_var_list TK_BAR statements TK_BLOCK_CLOSE
|
||||
{
|
||||
$$ = $4;
|
||||
[$$ setTemporaries:$2];
|
||||
}
|
||||
;
|
||||
block_var_list: TK_COLON variable_name
|
||||
{
|
||||
$$ = [NSMutableArray array];
|
||||
[$$ addObject:$2];
|
||||
}
|
||||
| block_var_list TK_COLON variable_name
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addObject:$3];
|
||||
}
|
||||
;
|
||||
statements:
|
||||
TK_RETURN expression
|
||||
{
|
||||
$$ = [STCStatements statements];
|
||||
[$$ setReturnExpression:$2];
|
||||
}
|
||||
| expressions
|
||||
{
|
||||
$$ = [STCStatements statements];
|
||||
[$$ setExpressions:$1];
|
||||
}
|
||||
|
||||
| expressions TK_DOT
|
||||
{
|
||||
$$ = [STCStatements statements];
|
||||
[$$ setExpressions:$1];
|
||||
}
|
||||
| expressions TK_DOT TK_RETURN expression
|
||||
{
|
||||
$$ = [STCStatements statements];
|
||||
[$$ setReturnExpression:$4];
|
||||
[$$ setExpressions:$1];
|
||||
}
|
||||
;
|
||||
|
||||
expressions:
|
||||
expression {
|
||||
$$ = [NSMutableArray array];
|
||||
[$$ addObject:$1];
|
||||
}
|
||||
|
||||
| expressions TK_DOT expression
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addObject:$3];
|
||||
}
|
||||
;
|
||||
expression: primary
|
||||
{
|
||||
$$ = [STCExpression
|
||||
/**/ primaryExpressionWithObject:$1];
|
||||
}
|
||||
| assignments primary
|
||||
{
|
||||
$$ = [STCExpression
|
||||
/**/ primaryExpressionWithObject:$2];
|
||||
[$$ setAssignments:$1];
|
||||
}
|
||||
| message_expression
|
||||
| assignments message_expression
|
||||
{
|
||||
$$ = $2;
|
||||
[$$ setAssignments:$1];
|
||||
}
|
||||
| cascade
|
||||
| assignments cascade
|
||||
{
|
||||
$$ = $2;
|
||||
[$$ setAssignments:$1];
|
||||
}
|
||||
;
|
||||
assignments: assignment
|
||||
{
|
||||
$$ = [NSMutableArray array];
|
||||
[$$ addObject:$1];
|
||||
}
|
||||
| assignments assignment
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addObject:$2];
|
||||
}
|
||||
;
|
||||
|
||||
assignment: variable_name TK_ASSIGNMENT
|
||||
{ $$ = $1;}
|
||||
|
||||
cascade: message_expression cascade_list
|
||||
{
|
||||
/* FIXME: check if this is this OK */
|
||||
[$$ setCascade:$2];
|
||||
}
|
||||
;
|
||||
cascade_list: TK_SEMICOLON cascade_item
|
||||
{
|
||||
$$ = [NSMutableArray array];
|
||||
[$$ addObject:$2];
|
||||
}
|
||||
| cascade_list TK_SEMICOLON cascade_item
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addObject:$3];
|
||||
}
|
||||
;
|
||||
cascade_item: unary_selector
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:nil];
|
||||
}
|
||||
| binary_selector unary_object
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:$2];
|
||||
}
|
||||
| keyword_expr_list
|
||||
;
|
||||
|
||||
message_expression: unary_expression
|
||||
| binary_expression
|
||||
| keyword_expression
|
||||
;
|
||||
unary_expression: unary_object unary_selector
|
||||
{
|
||||
STCMessage *message = [STCMessage message];
|
||||
[message addKeyword:$2 object:nil];
|
||||
$$ = [STCExpression
|
||||
/**/ messageExpressionWithTarget:$1
|
||||
/**/ message:message];
|
||||
}
|
||||
;
|
||||
binary_expression: binary_object binary_selector unary_object
|
||||
{
|
||||
STCMessage *message = [STCMessage message];
|
||||
[message addKeyword:$2 object:$3];
|
||||
$$ = [STCExpression
|
||||
/**/ messageExpressionWithTarget:$1
|
||||
/**/ message:message];
|
||||
}
|
||||
;
|
||||
keyword_expression: binary_object keyword_expr_list
|
||||
{
|
||||
$$ = [STCExpression
|
||||
/**/ messageExpressionWithTarget:$1
|
||||
/**/ message:$2];
|
||||
}
|
||||
keyword_expr_list: keyword binary_object
|
||||
{
|
||||
$$ = [STCMessage message];
|
||||
[$$ addKeyword:$1 object:$2];
|
||||
}
|
||||
| keyword_expr_list keyword binary_object
|
||||
{
|
||||
$$ = $1;
|
||||
[$$ addKeyword:$2 object:$3];
|
||||
}
|
||||
;
|
||||
unary_object: primary
|
||||
| unary_expression
|
||||
;
|
||||
binary_object: unary_object
|
||||
| binary_expression
|
||||
;
|
||||
primary: variable_name
|
||||
{
|
||||
$$ = [STCPrimary primaryWithVariable:$1];
|
||||
}
|
||||
| literal
|
||||
{
|
||||
$$ = [STCPrimary primaryWithLiteral:$1];
|
||||
}
|
||||
| block
|
||||
{
|
||||
$$ = [STCPrimary primaryWithBlock:$1];
|
||||
}
|
||||
| TK_LPAREN expression TK_RPAREN
|
||||
{
|
||||
$$ = [STCPrimary primaryWithExpression:$2];
|
||||
}
|
||||
;
|
||||
variable_name: TK_IDENTIFIER /* STCheckVariable ... */
|
||||
;
|
||||
unary_selector: TK_IDENTIFIER
|
||||
;
|
||||
binary_selector: TK_BINARY_SELECTOR
|
||||
;
|
||||
keyword: TK_KEYWORD
|
||||
;
|
||||
literal: TK_NUMBER
|
||||
{ $$ = [COMPILER createNumberLiteralFrom:$1]; }
|
||||
| TK_SYMBOL
|
||||
{ $$ = [COMPILER createSymbolLiteralFrom:$1]; }
|
||||
| TK_STRING
|
||||
{ $$ = [COMPILER createStringLiteralFrom:$1]; }
|
||||
| TK_CHARACTER
|
||||
{ $$ = [COMPILER createCharacterLiteralFrom:$1]; }
|
||||
| TK_ARRAY_OPEN array TK_RPAREN
|
||||
{ $$ = [COMPILER createArrayLiteralFrom:$2]; }
|
||||
;
|
||||
array: literal { $$ = [NSMutableArray array];
|
||||
[$$ addObject:$1]; }
|
||||
| symbol { $$ = [NSMutableArray array];
|
||||
[$$ addObject:$1]; }
|
||||
| array literal { $$ = $1; [$$ addObject:$2]; }
|
||||
| array symbol { $$ = $1; [$$ addObject:$2]; }
|
||||
;
|
||||
symbol: TK_IDENTIFIER
|
||||
{ $$ = [COMPILER createSymbolLiteralFrom:$1]; }
|
||||
| binary_selector
|
||||
{ $$ = [COMPILER createSymbolLiteralFrom:$1]; }
|
||||
| TK_KEYWORD
|
||||
{ $$ = [COMPILER createSymbolLiteralFrom:$1]; }
|
||||
|
||||
%%
|
||||
|
||||
int STCerror(const char *str)
|
||||
{
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Unknown parse error (%s)", str];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Lexer
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int STClex (YYSTYPE *lvalp, void *context)
|
||||
{
|
||||
STTokenType tokenType = [READER nextToken];
|
||||
|
||||
if(tokenType == STEndTokenType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
*lvalp = [READER tokenString];
|
||||
|
||||
switch(tokenType)
|
||||
{
|
||||
case STBarTokenType: return TK_BAR;
|
||||
case STReturnTokenType: return TK_RETURN;
|
||||
case STColonTokenType: return TK_COLON;
|
||||
case STSemicolonTokenType: return TK_SEMICOLON;
|
||||
case STDotTokenType: return TK_DOT;
|
||||
case STLParenTokenType: return TK_LPAREN;
|
||||
case STRParenTokenType: return TK_RPAREN;
|
||||
case STBlockOpenTokenType: return TK_BLOCK_OPEN;
|
||||
case STBlockCloseTokenType: return TK_BLOCK_CLOSE;
|
||||
case STArrayOpenTokenType: return TK_ARRAY_OPEN;
|
||||
case STAssignTokenType: return TK_ASSIGNMENT;
|
||||
case STIdentifierTokenType: return TK_IDENTIFIER;
|
||||
case STKeywordTokenType: return TK_KEYWORD;
|
||||
case STBinarySelectorTokenType: return TK_BINARY_SELECTOR;
|
||||
case STSymbolTokenType: return TK_SYMBOL;
|
||||
case STStringTokenType: return TK_STRING;
|
||||
case STCharacterTokenType: return TK_CHARACTER;
|
||||
case STNumberTokenType: return TK_NUMBER;
|
||||
case STSeparatorTokenType: return TK_SEPARATOR;
|
||||
|
||||
case STEndTokenType: return 0;
|
||||
|
||||
case STSharpTokenType:
|
||||
case STInvalidTokenType:
|
||||
case STErrorTokenType:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
49
Languages/Smalltalk/STLiterals.h
Normal file
49
Languages/Smalltalk/STLiterals.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
STLiterals.h
|
||||
Literal objects
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@interface STLiteral:NSObject
|
||||
@end
|
||||
|
||||
@interface STObjectReferenceLiteral:STLiteral
|
||||
{
|
||||
NSString *poolName;
|
||||
NSString *objectName;
|
||||
}
|
||||
- initWithObjectName:(NSString *)anObject poolName:(NSString *)aPool;
|
||||
- (NSString *)poolName;
|
||||
- (NSString *)objectName;
|
||||
@end
|
||||
|
||||
@interface STBlockLiteral:STLiteral
|
||||
{
|
||||
unsigned argCount;
|
||||
unsigned stackSize;
|
||||
}
|
||||
- initWithArgumentCount:(unsigned)count;
|
||||
- (void)setStackSize:(unsigned)size;
|
||||
- (unsigned)argumentCount;
|
||||
- (unsigned)stackSize;
|
||||
@end
|
86
Languages/Smalltalk/STLiterals.m
Normal file
86
Languages/Smalltalk/STLiterals.m
Normal file
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
STLiterals.h
|
||||
Literal objects
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STLiterals.h"
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
@implementation STLiteral
|
||||
@end
|
||||
|
||||
@implementation STObjectReferenceLiteral
|
||||
- initWithObjectName:(NSString *)anObject poolName:(NSString *)aPool
|
||||
{
|
||||
objectName = RETAIN(anObject);
|
||||
poolName = RETAIN(aPool);
|
||||
return [super init];
|
||||
}
|
||||
- copyWithZone:(NSZone *)zone
|
||||
{
|
||||
STObjectReferenceLiteral *copy = [super copyWithZone:zone];
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(objectName);
|
||||
RELEASE(poolName);
|
||||
[super dealloc];
|
||||
}
|
||||
- (NSString *)poolName
|
||||
{
|
||||
return poolName;
|
||||
}
|
||||
- (NSString *)objectName
|
||||
{
|
||||
return objectName;
|
||||
}
|
||||
- (NSString *)description
|
||||
{
|
||||
return [NSMutableString stringWithFormat:
|
||||
@"STObjectReferenceLiteral { object '%@', pool '%@' }",
|
||||
objectName,poolName];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation STBlockLiteral
|
||||
- initWithArgumentCount:(unsigned)count
|
||||
{
|
||||
argCount = count;
|
||||
return [super init];
|
||||
}
|
||||
- (void)setStackSize:(unsigned)size
|
||||
{
|
||||
stackSize = size;
|
||||
}
|
||||
- (unsigned)argumentCount
|
||||
{
|
||||
return argCount;
|
||||
}
|
||||
- (unsigned)stackSize
|
||||
{
|
||||
return stackSize;
|
||||
}
|
||||
@end
|
||||
|
43
Languages/Smalltalk/STMessage.h
Normal file
43
Languages/Smalltalk/STMessage.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
STMessage.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2001 Jun 18
|
||||
|
||||
This file is part of StepTalk.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSArray;
|
||||
|
||||
@interface STMessage:NSObject
|
||||
{
|
||||
NSString *selector;
|
||||
NSArray *args;
|
||||
}
|
||||
+ (STMessage *)messageWithSelector:(NSString *)selector
|
||||
arguments:(NSArray *)args;
|
||||
- initWithSelector:(NSString *)aString
|
||||
arguments:(NSArray *)anArray;
|
||||
- (NSString *)selector;
|
||||
- (NSArray*)arguments;
|
||||
@end
|
71
Languages/Smalltalk/STMessage.m
Normal file
71
Languages/Smalltalk/STMessage.m
Normal file
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
STMessage.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2001 Jun 18
|
||||
|
||||
This file is part of StepTalk.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import "STMessage.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
|
||||
@implementation STMessage
|
||||
+ (STMessage *)messageWithSelector:(NSString *)aString
|
||||
arguments:(NSArray *)anArray
|
||||
{
|
||||
STMessage *message;
|
||||
|
||||
message = [[STMessage alloc] initWithSelector:aString
|
||||
arguments:anArray];
|
||||
return AUTORELEASE(message);
|
||||
}
|
||||
- initWithSelector:(NSString *)aString
|
||||
arguments:(NSArray *)anArray
|
||||
{
|
||||
[super init];
|
||||
selector = RETAIN(aString);
|
||||
args = RETAIN(anArray);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(selector);
|
||||
RELEASE(args);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *)selector
|
||||
{
|
||||
return selector;
|
||||
}
|
||||
|
||||
- (NSArray *)arguments
|
||||
{
|
||||
return args;
|
||||
}
|
||||
@end
|
61
Languages/Smalltalk/STMethodContext.h
Normal file
61
Languages/Smalltalk/STMethodContext.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
STMethodContext.h
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STExecutionContext.h"
|
||||
|
||||
@class STCompiledMethod;
|
||||
@class STEnvironment;
|
||||
@class NSMutableArray;
|
||||
|
||||
@interface STMethodContext:STExecutionContext
|
||||
{
|
||||
STCompiledMethod *method;
|
||||
|
||||
NSMutableArray *temporaries;
|
||||
NSMutableArray *externs;
|
||||
|
||||
id receiver;
|
||||
}
|
||||
|
||||
+ methodContextWithMethod:(STCompiledMethod *)newMethod
|
||||
environment:(STEnvironment *)env;
|
||||
|
||||
- initWithMethod:(STCompiledMethod *)newMethod
|
||||
environment:(STEnvironment *)env;
|
||||
|
||||
- (STCompiledMethod*)method;
|
||||
|
||||
- (void)setReceiver:anObject;
|
||||
- (id)receiver;
|
||||
|
||||
- (void)setArgumentsFromArray:(NSArray *)args;
|
||||
|
||||
- (id)temporaryAtIndex:(unsigned)index;
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index;
|
||||
|
||||
- (id)externAtIndex:(unsigned)index;
|
||||
- (void)setExtern:anObject atIndex:(unsigned)index;
|
||||
|
||||
- (STBytecodes *)bytecodes;
|
||||
- (id)literalObjectAtIndex:(unsigned)index;
|
||||
@end
|
200
Languages/Smalltalk/STMethodContext.m
Normal file
200
Languages/Smalltalk/STMethodContext.m
Normal file
|
@ -0,0 +1,200 @@
|
|||
/**
|
||||
STMethodContext.m
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STMethodContext.h"
|
||||
|
||||
#import "STBytecodes.h"
|
||||
#import "STCompiledMethod.h"
|
||||
#import "STLiterals.h"
|
||||
#import "STStack.h"
|
||||
|
||||
#import <StepTalk/STEnvironment.h>
|
||||
#import <StepTalk/STExterns.h>
|
||||
#import <StepTalk/STObjectReference.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
@interface STMethodContext(STPrivateMethods)
|
||||
- (void)_resolveExternReferences:(NSArray *)array
|
||||
environment:(STEnvironment *)env;
|
||||
@end
|
||||
|
||||
@implementation STMethodContext
|
||||
+ methodContextWithMethod:(STCompiledMethod *)newMethod
|
||||
environment:(STEnvironment *)env
|
||||
{
|
||||
return AUTORELEASE([[self alloc] initWithMethod:newMethod environment:env]);
|
||||
}
|
||||
|
||||
- initWithMethod:(STCompiledMethod *)newMethod
|
||||
environment:(STEnvironment *)env
|
||||
{
|
||||
unsigned int tempCount;
|
||||
unsigned int i;
|
||||
|
||||
method = RETAIN(newMethod);
|
||||
|
||||
tempCount = [method temporariesCount];
|
||||
temporaries = [[NSMutableArray alloc] initWithCapacity:tempCount];
|
||||
|
||||
for(i=0;i<tempCount;i++)
|
||||
{
|
||||
[temporaries insertObject:STNil atIndex:i];
|
||||
}
|
||||
|
||||
[self _resolveExternReferences:[method externReferences]
|
||||
environment:env];
|
||||
|
||||
return [super initWithStackSize:[method stackSize]];
|
||||
}
|
||||
|
||||
- (void)_resolveExternReferences:(NSArray *)array
|
||||
environment:(STEnvironment *)env
|
||||
{
|
||||
STObjectReferenceLiteral *lit;
|
||||
STObjectReference *ref;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@"Resolving external references...");
|
||||
|
||||
externs = [[NSMutableArray alloc] init];
|
||||
|
||||
count = [array count];
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
lit = [array objectAtIndex:i];
|
||||
|
||||
NSDebugLLog(@"STBytecodeInterpreter",
|
||||
@" '%@' (%@)",[lit objectName], [lit poolName]);
|
||||
|
||||
/* FIXME: use pools */
|
||||
ref = [env objectReferenceForObjectWithName:[lit objectName]];
|
||||
|
||||
if(![ref object])
|
||||
{
|
||||
[NSException raise:STGenericException
|
||||
format:@"Unknown object with name '%@' "
|
||||
@"in pool '%@'",
|
||||
[lit objectName], [lit poolName]];
|
||||
}
|
||||
[externs addObject:ref];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(temporaries);
|
||||
RELEASE(method);
|
||||
RELEASE(externs);
|
||||
[super dealloc];
|
||||
}
|
||||
- (BOOL)isBlockContext
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
- (STMethodContext *)homeContext
|
||||
{
|
||||
return self;
|
||||
}
|
||||
- (void)setHomeContext:(STMethodContext *)context
|
||||
{
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"Should not set home context of method context"];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
RELEASE(method);
|
||||
method = nil;
|
||||
}
|
||||
- (BOOL)isInvalid
|
||||
{
|
||||
return (!method);
|
||||
}
|
||||
|
||||
- (STCompiledMethod*)method
|
||||
{
|
||||
return method;
|
||||
}
|
||||
- (void)setReceiver:anObject
|
||||
{
|
||||
receiver = anObject;
|
||||
}
|
||||
- (id)receiver
|
||||
{
|
||||
return receiver;
|
||||
}
|
||||
|
||||
- (id)temporaryAtIndex:(unsigned)index
|
||||
{
|
||||
return [temporaries objectAtIndex:index];
|
||||
}
|
||||
|
||||
- (void)setTemporary:anObject atIndex:(unsigned)index
|
||||
{
|
||||
if(!anObject)
|
||||
{
|
||||
anObject = STNil;
|
||||
}
|
||||
[temporaries replaceObjectAtIndex:index withObject:anObject];
|
||||
}
|
||||
|
||||
- (id)externAtIndex:(unsigned)index
|
||||
{
|
||||
STObjectReference *ref = [externs objectAtIndex:index];
|
||||
return [ref object];
|
||||
}
|
||||
|
||||
- (void)setExtern:anObject atIndex:(unsigned)index
|
||||
{
|
||||
STObjectReference *reference = [externs objectAtIndex:index];
|
||||
|
||||
[reference setObject:anObject];
|
||||
}
|
||||
- (STBytecodes *)bytecodes
|
||||
{
|
||||
return [method bytecodes];
|
||||
}
|
||||
- (id)literalObjectAtIndex:(unsigned)index
|
||||
{
|
||||
return [method literalObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (void)setArgumentsFromArray:(NSArray *)args
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
|
||||
count = [args count];
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
[self setTemporary:[args objectAtIndex:i] atIndex:i];
|
||||
}
|
||||
}
|
||||
@end
|
46
Languages/Smalltalk/STScriptObject.h
Normal file
46
Languages/Smalltalk/STScriptObject.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
STScriptObject.h
|
||||
Object that represents script
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSMutableArray;
|
||||
@class NSMutableDictionary;
|
||||
@class STBytecodeInterpreter;
|
||||
@class STCompiledScript;
|
||||
@class STEnvironment;
|
||||
|
||||
@interface STScriptObject:NSObject
|
||||
{
|
||||
NSString *name;
|
||||
STBytecodeInterpreter *interpreter;
|
||||
STEnvironment *environment;
|
||||
STCompiledScript *script;
|
||||
NSMutableArray *variables;
|
||||
}
|
||||
- initWithEnvironment:(STEnvironment *)env
|
||||
compiledScript:(STCompiledScript *)compiledScript;
|
||||
|
||||
- (void)setInstanceVariable:(id)anObject atIndex:(int)anIndex;
|
||||
- (id)instanceVariableAtIndex:(int)anIndex;
|
||||
@end
|
170
Languages/Smalltalk/STScriptObject.m
Normal file
170
Languages/Smalltalk/STScriptObject.m
Normal file
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
STScriptObject.m
|
||||
Object that represents script
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "STScriptObject.h"
|
||||
|
||||
#import "STBytecodeInterpreter.h"
|
||||
#import "STCompiledScript.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSMethodSignature.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <StepTalk/NSInvocation+additions.h>
|
||||
#import <StepTalk/STEnvironment.h>
|
||||
#import <StepTalk/STObjCRuntime.h>
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
@implementation STScriptObject
|
||||
- initWithEnvironment:(STEnvironment *)env
|
||||
compiledScript:(STCompiledScript *)compiledScript
|
||||
{
|
||||
int count = [compiledScript variableCount];
|
||||
int i;
|
||||
|
||||
[super init];
|
||||
|
||||
NSDebugLLog(@"STEngine",
|
||||
@"creating script object %p with %i ivars",compiledScript,
|
||||
count);
|
||||
|
||||
environment = RETAIN(env);
|
||||
script = RETAIN(compiledScript);
|
||||
variables = [[NSMutableArray alloc] initWithCapacity:count];
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
[variables addObject:STNil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(interpreter);
|
||||
RELEASE(script);
|
||||
RELEASE(variables);
|
||||
RELEASE(environment);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
- (STCompiledScript *)script
|
||||
{
|
||||
return script;
|
||||
}
|
||||
- (void)setInstanceVariable:(id)anObject atIndex:(int)anIndex;
|
||||
{
|
||||
if(anObject == nil)
|
||||
{
|
||||
anObject = STNil;
|
||||
}
|
||||
|
||||
[variables replaceObjectAtIndex:anIndex withObject:anObject];
|
||||
}
|
||||
- (id)instanceVariableAtIndex:(int)anIndex;
|
||||
{
|
||||
return [[variables objectAtIndex:anIndex] self];
|
||||
}
|
||||
|
||||
- (BOOL)respondsToSelector:(SEL)aSelector
|
||||
{
|
||||
if( [super respondsToSelector:(SEL)aSelector] )
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
return ([script methodWithName:NSStringFromSelector(aSelector)] != nil);
|
||||
}
|
||||
|
||||
|
||||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel
|
||||
{
|
||||
NSMethodSignature *signature = nil;
|
||||
|
||||
signature = [super methodSignatureForSelector:sel];
|
||||
|
||||
if(!signature)
|
||||
{
|
||||
signature = STMethodSignatureForSelector(sel);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
- (void) forwardInvocation:(NSInvocation *)invocation
|
||||
{
|
||||
STCompiledMethod *method;
|
||||
NSString *methodName = NSStringFromSelector([invocation selector]);
|
||||
NSMutableArray *args;
|
||||
id arg;
|
||||
int index;
|
||||
int count;
|
||||
id retval = nil;
|
||||
|
||||
if(!interpreter)
|
||||
{
|
||||
NSDebugLLog(@"STEngine",
|
||||
@"creating new interpreter for script '%@'",
|
||||
name);
|
||||
interpreter = [[STBytecodeInterpreter alloc] init];
|
||||
[interpreter setEnvironment:environment];
|
||||
}
|
||||
|
||||
|
||||
if([methodName isEqualToString:@"exit"])
|
||||
{
|
||||
[interpreter halt];
|
||||
return;
|
||||
}
|
||||
|
||||
method = [script methodWithName:methodName];
|
||||
|
||||
[interpreter setReceiver:self];
|
||||
|
||||
count = [[invocation methodSignature] numberOfArguments];
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@"script object perform: %@ with %i args",
|
||||
methodName,count-2);
|
||||
|
||||
args = [NSMutableArray array];
|
||||
|
||||
for(index = 2; index < count; index++)
|
||||
{
|
||||
arg = [invocation getArgumentAsObjectAtIndex:index];
|
||||
[args addObject:arg];
|
||||
}
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@">> forwarding to self ...");
|
||||
|
||||
retval = [interpreter executeCompiledMethod:method withArguments:args];
|
||||
|
||||
NSDebugLLog(@"STSending",
|
||||
@"<< returned from forwarding");
|
||||
|
||||
[invocation setReturnValue:&retval];
|
||||
}
|
||||
@end
|
30
Languages/Smalltalk/STSelector+additions.h
Normal file
30
Languages/Smalltalk/STSelector+additions.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
STSelector additions
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
Date: 2002 Feb 4
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <StepTalk/STSelector.h>
|
||||
|
||||
@interface STSelector(SmalltalkCompiler)
|
||||
+ symbolFromString:(NSString *)aString;
|
||||
@end
|
||||
|
34
Languages/Smalltalk/STSelector+additions.m
Normal file
34
Languages/Smalltalk/STSelector+additions.m
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
STSelector additions
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
Date: 2002 Feb 4
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import "STSelector+additions.h"
|
||||
|
||||
@implementation STSelector(SmalltalkCompiler)
|
||||
+ symbolFromString:(NSString *)aString
|
||||
{
|
||||
STSelector *aSel;
|
||||
aSel = [[STSelector alloc] initWithSelector:STSelectorFromString(aString)];
|
||||
return AUTORELEASE(aSel);
|
||||
}
|
||||
@end
|
48
Languages/Smalltalk/STSourceReader.h
Normal file
48
Languages/Smalltalk/STSourceReader.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
STSourceReader.h
|
||||
Source reader class.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSRange.h>
|
||||
|
||||
#include "STTokenTypes.h"
|
||||
|
||||
|
||||
@class NSString;
|
||||
|
||||
@interface STSourceReader:NSObject
|
||||
{
|
||||
NSString *source; // Source
|
||||
NSRange srcRange; // range of source in string
|
||||
int srcOffset; // Scan offset
|
||||
NSRange tokenRange; // Tokenn range
|
||||
STTokenType tokenType; // Token type
|
||||
}
|
||||
- initWithString:(NSString *)aString;
|
||||
- initWithString:(NSString *)aString range:(NSRange)range;
|
||||
- (STTokenType)nextToken;
|
||||
- (STTokenType)tokenType;
|
||||
- (NSString *)tokenString;
|
||||
- (NSRange)tokenRange;
|
||||
- (int)currentLine;
|
||||
|
||||
@end
|
488
Languages/Smalltalk/STSourceReader.m
Normal file
488
Languages/Smalltalk/STSourceReader.m
Normal file
|
@ -0,0 +1,488 @@
|
|||
/**
|
||||
STSourceReader.m
|
||||
Source reader class.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
|
||||
#import "STSourceReader.h"
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSCharacterSet.h>
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import "Externs.h"
|
||||
|
||||
static NSCharacterSet *identStartCharacterSet;
|
||||
static NSCharacterSet *identCharacterSet;
|
||||
static NSCharacterSet *wsCharacterSet;
|
||||
static NSCharacterSet *numericCharacterSet;
|
||||
static NSCharacterSet *symbolicSelectorCharacterSet;
|
||||
static NSCharacterSet *validCharacterCharacterSet;
|
||||
|
||||
#define AT_END (srcOffset >= NSMaxRange(srcRange))
|
||||
// #define AT_END ([self atEnd])
|
||||
|
||||
@interface NSString (LineCounting)
|
||||
- (int)lineNumberForIndex:(int)index;
|
||||
@end
|
||||
|
||||
@implementation NSString (LineCounting)
|
||||
- (int)lineNumberForIndex:(int)index
|
||||
{
|
||||
int i, len;
|
||||
int cr = 0;
|
||||
int line = 1;
|
||||
len = [self length];
|
||||
index = (index < len) ? index : len;
|
||||
|
||||
for(i=0;i<index;i++)
|
||||
{
|
||||
switch([self characterAtIndex:i])
|
||||
{
|
||||
case 0x000a: if(cr)
|
||||
{ cr = 0; break; }
|
||||
case 0x000d: cr = 1;
|
||||
case 0x2028:
|
||||
case 0x2029: cr = 0;
|
||||
line++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#define PEEK_CHAR [source characterAtIndex:srcOffset]
|
||||
#define GET_CHAR [source characterAtIndex:srcOffset++]
|
||||
|
||||
/*
|
||||
static unichar (*characterAtIndex)(NSString*, SEL, unsigned int);
|
||||
static unichar (*characterIsMember)(NSCharacterSet*, SEL, unichar);
|
||||
*/
|
||||
|
||||
/* FIXME: temporary (slow) solution */
|
||||
|
||||
@interface NSMutableString(CharacterAppending)
|
||||
- (void)appendCharacter:(unichar)character;
|
||||
@end
|
||||
@implementation NSMutableString(CharacterAppending)
|
||||
- (void)appendCharacter:(unichar)character
|
||||
{
|
||||
[self appendString:[NSString stringWithCharacters:&character
|
||||
length:1]];
|
||||
}
|
||||
@end
|
||||
|
||||
static NSString *_STNormalizeStringToken(NSString *token)
|
||||
{
|
||||
NSMutableString *string = [NSMutableString string];
|
||||
unsigned int i;
|
||||
unichar c;
|
||||
unsigned int len = [token length];
|
||||
|
||||
for(i = 0;i < len; i++)
|
||||
{
|
||||
c = [token characterAtIndex:i];
|
||||
if(c == '\\')
|
||||
{
|
||||
i++;
|
||||
c = [token characterAtIndex:i];
|
||||
switch(c)
|
||||
{
|
||||
case 'a': [string appendCharacter:'\a']; break;
|
||||
case 'b': [string appendCharacter:'\b']; break;
|
||||
case 'e': [string appendCharacter:'\e']; break;
|
||||
case 'n': [string appendCharacter:'\n']; break;
|
||||
case 'r': [string appendCharacter:'\r']; break;
|
||||
case 't': [string appendCharacter:'\t']; break;
|
||||
case 'v': [string appendCharacter:'\v']; break;
|
||||
default:[string appendCharacter:c]; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[string appendCharacter:c];
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@implementation STSourceReader
|
||||
+ (void)initialize
|
||||
{
|
||||
NSMutableCharacterSet *set;
|
||||
|
||||
set = [[NSCharacterSet letterCharacterSet] mutableCopy];
|
||||
[set addCharactersInString:@"_"];
|
||||
identStartCharacterSet = [set copy];
|
||||
|
||||
[set formUnionWithCharacterSet:[NSCharacterSet decimalDigitCharacterSet]];
|
||||
identCharacterSet = [set copy];
|
||||
|
||||
RELEASE(set);
|
||||
|
||||
wsCharacterSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
numericCharacterSet = [NSCharacterSet decimalDigitCharacterSet];
|
||||
symbolicSelectorCharacterSet =
|
||||
[NSCharacterSet characterSetWithCharactersInString:
|
||||
@"%&*+-,/<=>?@\\~"];
|
||||
|
||||
RETAIN(wsCharacterSet);
|
||||
RETAIN(numericCharacterSet);
|
||||
RETAIN(symbolicSelectorCharacterSet);
|
||||
|
||||
/*
|
||||
set = [[NSCharacterSet alphanumericCharacterSet] mutableCopy];
|
||||
[set formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
|
||||
[set formUnionWithCharacterSet:[NSCharacterSet nonBaseCharacterSet]];
|
||||
*/
|
||||
set = [[NSCharacterSet controlCharacterSet] mutableCopy];
|
||||
[set formUnionWithCharacterSet:[NSCharacterSet illegalCharacterSet]];
|
||||
[set formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||||
|
||||
validCharacterCharacterSet = RETAIN([set invertedSet]);
|
||||
|
||||
RELEASE(set);
|
||||
/*
|
||||
characterAtIndex = (unichar (*)(NSString*, SEL, unsigned int))
|
||||
[NSString instanceMethodForSelector: @selector(characterAtIndex:)];
|
||||
characterIsMember = (unichar (*)(NSString*, SEL, unsigned int))
|
||||
[NSCharacterSet instanceMethodForSelector: @selector(characterAtIndex:)];
|
||||
*/
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE(source);
|
||||
}
|
||||
|
||||
|
||||
- initWithString:(NSString *)aString
|
||||
{
|
||||
return [self initWithString:aString range:NSMakeRange(0,[aString length])];
|
||||
}
|
||||
|
||||
- initWithString:(NSString *)aString range:(NSRange)range
|
||||
{
|
||||
[super init];
|
||||
|
||||
ASSIGN(source,aString);
|
||||
srcRange = range;
|
||||
srcOffset = range.location;
|
||||
tokenRange = NSMakeRange(0,0);
|
||||
tokenType = STInvalidTokenType;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (STTokenType) tokenType
|
||||
{
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
- (NSString *)tokenString
|
||||
{
|
||||
|
||||
if(tokenType == STStringTokenType)
|
||||
{
|
||||
return _STNormalizeStringToken([source substringWithRange:tokenRange]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return [source substringWithRange:tokenRange];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSRange)tokenRange;
|
||||
{
|
||||
return tokenRange;
|
||||
}
|
||||
|
||||
- (BOOL) atEnd
|
||||
{
|
||||
return (srcOffset >= NSMaxRange(srcRange));
|
||||
}
|
||||
|
||||
- (int) currentLine
|
||||
{
|
||||
return [source lineNumberForIndex:srcOffset];
|
||||
}
|
||||
|
||||
- (BOOL) eatWhiteSpace
|
||||
{
|
||||
unichar uc;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(AT_END)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uc = PEEK_CHAR;
|
||||
|
||||
/* treat comments as whitespace */
|
||||
if(uc == '"')
|
||||
{
|
||||
unsigned int start = srcOffset;
|
||||
do
|
||||
{
|
||||
srcOffset++;
|
||||
if(AT_END)
|
||||
{
|
||||
tokenRange = NSMakeRange(start, 1);
|
||||
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Unterminated comment"];
|
||||
return 1;
|
||||
}
|
||||
} while(PEEK_CHAR != '"');
|
||||
}
|
||||
else if([wsCharacterSet characterIsMember:uc] == NO)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
srcOffset++;
|
||||
}
|
||||
}
|
||||
|
||||
- (STTokenType)readNextToken
|
||||
{
|
||||
unichar c;
|
||||
int start;
|
||||
|
||||
if([self eatWhiteSpace])
|
||||
{
|
||||
return STErrorTokenType;
|
||||
}
|
||||
|
||||
if(AT_END)
|
||||
{
|
||||
return STEndTokenType;
|
||||
}
|
||||
|
||||
c = PEEK_CHAR;
|
||||
|
||||
if([identStartCharacterSet characterIsMember:c])
|
||||
{
|
||||
start=srcOffset++;
|
||||
while([identCharacterSet characterIsMember:c])
|
||||
{
|
||||
c = GET_CHAR;
|
||||
if(AT_END)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
srcOffset--;
|
||||
if(!AT_END)
|
||||
{
|
||||
c = PEEK_CHAR;
|
||||
if(c == ':')
|
||||
{
|
||||
c = GET_CHAR;
|
||||
if(c=='=')
|
||||
{
|
||||
srcOffset--; /* we got := */
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STKeywordTokenType;
|
||||
}
|
||||
}
|
||||
}
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STIdentifierTokenType;
|
||||
}
|
||||
else if ( c == '-' || [numericCharacterSet characterIsMember:c])
|
||||
{
|
||||
start=srcOffset;
|
||||
|
||||
c = GET_CHAR;
|
||||
|
||||
while([numericCharacterSet characterIsMember:c])
|
||||
{
|
||||
c = GET_CHAR;
|
||||
if(AT_END)
|
||||
break;
|
||||
}
|
||||
|
||||
srcOffset--;
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
|
||||
c = PEEK_CHAR;
|
||||
if([identCharacterSet characterIsMember:c])
|
||||
{
|
||||
tokenRange = NSMakeRange(start,srcOffset - start + 1);
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Letters in number"];
|
||||
return STErrorTokenType;
|
||||
}
|
||||
return STNumberTokenType;
|
||||
|
||||
}
|
||||
else if ([symbolicSelectorCharacterSet characterIsMember:c])
|
||||
{
|
||||
start = srcOffset++;
|
||||
c = PEEK_CHAR;
|
||||
if ([symbolicSelectorCharacterSet characterIsMember:c])
|
||||
{
|
||||
srcOffset++;
|
||||
tokenRange = NSMakeRange(start,2);
|
||||
}
|
||||
else
|
||||
tokenRange = NSMakeRange(start,1);
|
||||
return STBinarySelectorTokenType;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case '$':
|
||||
srcOffset++;
|
||||
c = GET_CHAR;
|
||||
if(AT_END)
|
||||
{
|
||||
tokenRange = NSMakeRange(srcOffset-2, 1);
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Character expected"];
|
||||
return STErrorTokenType;
|
||||
};
|
||||
|
||||
if([validCharacterCharacterSet characterIsMember:c])
|
||||
{
|
||||
c = PEEK_CHAR;
|
||||
if([identCharacterSet characterIsMember:c])
|
||||
{
|
||||
tokenRange = NSMakeRange(srcOffset-2, 3);
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Too many characters"];
|
||||
return STErrorTokenType;
|
||||
}
|
||||
|
||||
tokenRange = NSMakeRange(srcOffset++,1);\
|
||||
return STCharacterTokenType;
|
||||
}
|
||||
|
||||
tokenRange = NSMakeRange(srcOffset-2,2);\
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Invalid character literal"];
|
||||
return STErrorTokenType;
|
||||
|
||||
case '#':
|
||||
start=srcOffset++;
|
||||
c = PEEK_CHAR;
|
||||
if(c=='(')
|
||||
{
|
||||
srcOffset++;
|
||||
tokenRange = NSMakeRange(start,2);
|
||||
return STArrayOpenTokenType;
|
||||
}
|
||||
|
||||
if([identStartCharacterSet characterIsMember:c])
|
||||
{
|
||||
start=srcOffset++;
|
||||
while([identCharacterSet characterIsMember:c] || c == ':')
|
||||
{
|
||||
c = GET_CHAR;
|
||||
if(AT_END)
|
||||
break;
|
||||
}
|
||||
srcOffset--;
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STSymbolTokenType;
|
||||
}
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STSharpTokenType;
|
||||
case ':':
|
||||
start=srcOffset++;
|
||||
c = PEEK_CHAR;
|
||||
if(c == '=')
|
||||
{
|
||||
srcOffset++;
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STAssignTokenType;
|
||||
}
|
||||
tokenRange = NSMakeRange(start,srcOffset - start);
|
||||
return STColonTokenType;
|
||||
|
||||
#define SIMPLE_TOKEN_RETURN(type) \
|
||||
tokenRange = NSMakeRange(srcOffset++,1);\
|
||||
return type
|
||||
|
||||
case '(':SIMPLE_TOKEN_RETURN(STLParenTokenType);
|
||||
case ')':SIMPLE_TOKEN_RETURN(STRParenTokenType);
|
||||
case '|':SIMPLE_TOKEN_RETURN(STBarTokenType);
|
||||
case ';':SIMPLE_TOKEN_RETURN(STSemicolonTokenType);
|
||||
case '[':SIMPLE_TOKEN_RETURN(STBlockOpenTokenType);
|
||||
case ']':SIMPLE_TOKEN_RETURN(STBlockCloseTokenType);
|
||||
case '^':SIMPLE_TOKEN_RETURN(STReturnTokenType);
|
||||
case '!':SIMPLE_TOKEN_RETURN(STSeparatorTokenType);
|
||||
case '.':SIMPLE_TOKEN_RETURN(STDotTokenType);
|
||||
case '\'':
|
||||
start= 1 + srcOffset++;
|
||||
for(;;)
|
||||
{
|
||||
|
||||
if(AT_END)
|
||||
{
|
||||
tokenRange = NSMakeRange(start-1,1);\
|
||||
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"Unterminated string"];
|
||||
return STErrorTokenType;
|
||||
};
|
||||
|
||||
c = GET_CHAR;
|
||||
if( c=='\\')
|
||||
{
|
||||
if(AT_END)
|
||||
{
|
||||
[NSException raise:STCompilerSyntaxException
|
||||
format:@"\\ at end"];
|
||||
return STErrorTokenType;
|
||||
}
|
||||
|
||||
GET_CHAR;
|
||||
}
|
||||
else if( c=='\'' )
|
||||
{
|
||||
if(AT_END)
|
||||
{
|
||||
return STStringTokenType;
|
||||
}
|
||||
|
||||
c = GET_CHAR;
|
||||
if(c != '\'')
|
||||
{
|
||||
srcOffset--;
|
||||
tokenRange = NSMakeRange(start,
|
||||
srcOffset - start - 1);
|
||||
return STStringTokenType;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
default: return STErrorTokenType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (STTokenType)nextToken
|
||||
{
|
||||
tokenType = [self readNextToken];
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
- (void)unreadLastToken
|
||||
{
|
||||
srcOffset = tokenRange.location;
|
||||
}
|
||||
@end
|
45
Languages/Smalltalk/STStack.h
Normal file
45
Languages/Smalltalk/STStack.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
STStack.h
|
||||
Stack object
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@interface STStack:NSObject
|
||||
{
|
||||
unsigned size;
|
||||
unsigned pointer;
|
||||
id *stack;
|
||||
}
|
||||
+ stackWithSize:(unsigned)newSize;
|
||||
- initWithSize:(unsigned)newSize;
|
||||
|
||||
- (void)push:anObject;
|
||||
- (id) pop;
|
||||
- (void)popCount:(unsigned)count;
|
||||
- (id) valueAtTop;
|
||||
- (id) valueFromTop:(unsigned)offset;
|
||||
|
||||
- (void)duplicateTop;
|
||||
|
||||
- (void)empty;
|
||||
@end
|
128
Languages/Smalltalk/STStack.m
Normal file
128
Languages/Smalltalk/STStack.m
Normal file
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
STStack.m
|
||||
Temporaries and stack storage.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
|
||||
#import "STStack.h"
|
||||
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
|
||||
@implementation STStack
|
||||
+ stackWithSize:(unsigned)newSize
|
||||
{
|
||||
return AUTORELEASE([[self alloc] initWithSize:newSize]);
|
||||
}
|
||||
|
||||
- initWithSize:(unsigned)newSize
|
||||
{
|
||||
size = newSize;
|
||||
pointer = 0;
|
||||
stack = NSZoneMalloc( NSDefaultMallocZone(), size * sizeof(id) );
|
||||
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (void)invalidPointer:(unsigned)ptr
|
||||
{
|
||||
[NSException raise:STInternalInconsistencyException
|
||||
format:@"%s (%p): invalid pointer %i (sp=%i size=%i)",
|
||||
[self name],self,
|
||||
ptr,
|
||||
pointer,
|
||||
size];
|
||||
}
|
||||
- (void)dealloc
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(),stack);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#define INDEX_IS_VALID(index) \
|
||||
((index >= 0) && (index < size))
|
||||
|
||||
#define CHECK_POINTER(value) \
|
||||
do {\
|
||||
if(!INDEX_IS_VALID(value)) \
|
||||
{\
|
||||
[self invalidPointer:value];\
|
||||
} \
|
||||
}\
|
||||
while(0)
|
||||
/*
|
||||
- (void)setPointer:(unsigned)newPointer
|
||||
{
|
||||
CHECK_POINTER(newPointer);
|
||||
pointer=newPointer;
|
||||
}
|
||||
*/
|
||||
|
||||
- (int)pointer
|
||||
{
|
||||
return pointer;
|
||||
}
|
||||
|
||||
- (void)push:(id)value
|
||||
{
|
||||
CHECK_POINTER(pointer);
|
||||
|
||||
NSDebugLLog(@"STStack",@"stack:%p %02i push '%@'",self,pointer,value);
|
||||
|
||||
stack[pointer++] = value;
|
||||
}
|
||||
|
||||
- (void)duplicateTop
|
||||
{
|
||||
[self push:[self valueAtTop]];
|
||||
}
|
||||
#define CONVERT_NIL(obj) ((obj == STNil) ? nil : (obj))
|
||||
- (id)valueAtTop
|
||||
{
|
||||
CHECK_POINTER(pointer-1);
|
||||
|
||||
return CONVERT_NIL(stack[pointer-1]);
|
||||
}
|
||||
- (id)valueFromTop:(unsigned)index
|
||||
{
|
||||
id value;
|
||||
|
||||
CHECK_POINTER(pointer-index-1);
|
||||
|
||||
value = stack[pointer - index - 1];
|
||||
NSDebugLLog(@"STStack",@"stack:%p %02i from top %i '%@'",
|
||||
self,pointer,index,value);
|
||||
|
||||
return CONVERT_NIL(value);
|
||||
}
|
||||
|
||||
- (id)pop
|
||||
{
|
||||
CHECK_POINTER(pointer-1);
|
||||
|
||||
NSDebugLLog(@"STStack",@"stack:%p %02i pop '%@'",self,pointer,stack[pointer-1]);
|
||||
|
||||
pointer --;
|
||||
return CONVERT_NIL(stack[pointer]);
|
||||
}
|
||||
|
||||
- (void)popCount:(unsigned)count
|
||||
{
|
||||
CHECK_POINTER(pointer-count);
|
||||
|
||||
NSDebugLLog(@"STStack",@"stack:%p %02i pop count %i (%i)",self,
|
||||
pointer,count,pointer-count);
|
||||
pointer -= count;
|
||||
}
|
||||
- (void)empty
|
||||
{
|
||||
pointer = 0;
|
||||
}
|
||||
|
||||
@end
|
56
Languages/Smalltalk/STTokenTypes.h
Normal file
56
Languages/Smalltalk/STTokenTypes.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
STTokenTypes.h
|
||||
STSourceReader token types
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StpTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STInvalidTokenType,
|
||||
STSeparatorTokenType, // !
|
||||
STBarTokenType, // |
|
||||
STReturnTokenType, // ^
|
||||
STColonTokenType, // :
|
||||
STSemicolonTokenType, // ;
|
||||
STDotTokenType, // .
|
||||
STLParenTokenType, // (
|
||||
STRParenTokenType, // )
|
||||
STBlockOpenTokenType, // [
|
||||
STBlockCloseTokenType, // ]
|
||||
STArrayOpenTokenType, // #(
|
||||
STSharpTokenType, // #
|
||||
STAssignTokenType, // :=
|
||||
|
||||
STErrorTokenType,
|
||||
STIdentifierTokenType, // thisIsIdentifier
|
||||
STKeywordTokenType, // thisIsKeyword:
|
||||
|
||||
STBinarySelectorTokenType, // +,-,*,/
|
||||
STSymbolTokenType, // #thisIsSymbol
|
||||
STStringTokenType, // 'This is string'
|
||||
|
||||
STCharacterTokenType, // $a (any single alphanum character)
|
||||
STNumberTokenType, // -?[0-9]+
|
||||
|
||||
STMethodTokenType, // method token (for chunk reader)
|
||||
|
||||
STEndTokenType
|
||||
|
||||
} STTokenType;
|
36
Languages/Smalltalk/STUndefinedObject+additions.h
Normal file
36
Languages/Smalltalk/STUndefinedObject+additions.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
STUndefinedObject.h
|
||||
Wrapper for nil object
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#import <StepTalk/STUndefinedObject.h>
|
||||
|
||||
@class STBlock;
|
||||
|
||||
@interface STUndefinedObject(SmalltalkAdditions)
|
||||
- ifFalse:(STBlock *)block ifTrue:(STBlock *)anotherBlock;
|
||||
- ifTrue:(STBlock *)block ifFalse:(STBlock *)anotherBlock;
|
||||
- ifTrue:(STBlock *)block;
|
||||
- ifFalse:(STBlock *)block;
|
||||
- ifNil:(STBlock *)block;
|
||||
- notNil:(STBlock *)block;
|
||||
- (BOOL)isNil;
|
||||
@end
|
54
Languages/Smalltalk/STUndefinedObject+additions.m
Normal file
54
Languages/Smalltalk/STUndefinedObject+additions.m
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
STUndefinedObject.m
|
||||
Wrapper for nil object
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
*/
|
||||
#import "STUndefinedObject+additions.h"
|
||||
|
||||
#import "STBlock.h"
|
||||
#import <StepTalk/STExterns.h>
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
@implementation STUndefinedObject(SmalltalkAdditions)
|
||||
- (BOOL)isNil
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- ifNil:(STBlock *)block
|
||||
{
|
||||
return [block value];
|
||||
}
|
||||
|
||||
- notNil:(STBlock *)block
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- ifFalse:(STBlock *)block
|
||||
{
|
||||
return [block value];
|
||||
}
|
||||
|
||||
- ifTrue:(STBlock *)block
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- ifFalse:(STBlock *)block ifTrue:(STBlock *)anotherBlock
|
||||
{
|
||||
return [block value];
|
||||
}
|
||||
|
||||
- ifTrue:(STBlock *)block ifFalse:(STBlock *)anotherBlock
|
||||
{
|
||||
return [anotherBlock value];
|
||||
}
|
||||
@end
|
||||
|
32
Languages/Smalltalk/SmalltalkEngine.h
Normal file
32
Languages/Smalltalk/SmalltalkEngine.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
SmalltalkEngine
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2001 Oct 24
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <StepTalk/STEngine.h>
|
||||
|
||||
@interface SmalltalkEngine:STEngine
|
||||
{
|
||||
}
|
||||
@end
|
80
Languages/Smalltalk/SmalltalkEngine.m
Normal file
80
Languages/Smalltalk/SmalltalkEngine.m
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
SmalltalkEngine
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
Date: 2001 Oct 24
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "SmalltalkEngine.h"
|
||||
|
||||
#import "STBytecodeInterpreter.h"
|
||||
#import "STCompiler.h"
|
||||
#import "STCompiledCode.h"
|
||||
|
||||
#import <StepTalk/STEnvironment.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
||||
@implementation SmalltalkEngine
|
||||
- (BOOL)canExecuteCode:(NSString *)sourceCode
|
||||
{
|
||||
STCompiler *compiler;
|
||||
STCompiledCode *code = nil;
|
||||
BOOL retval = NO;
|
||||
|
||||
compiler = [[STCompiler alloc] init];
|
||||
|
||||
NS_DURING
|
||||
code = [compiler compileString:sourceCode];
|
||||
NS_HANDLER
|
||||
NSLog(@"Smalltalk: Ignoring: %@", [localException reason]);
|
||||
NS_ENDHANDLER
|
||||
|
||||
if(code)
|
||||
{
|
||||
retval = YES;
|
||||
}
|
||||
|
||||
RELEASE(compiler);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
- (id) executeCode:(NSString *)sourceCode
|
||||
inEnvironment:(STEnvironment *)env
|
||||
{
|
||||
STCompiler *compiler;
|
||||
STCompiledScript *script;
|
||||
id retval = nil;
|
||||
|
||||
compiler = [[STCompiler alloc] init];
|
||||
|
||||
[compiler setEnvironment:env];
|
||||
|
||||
script = [compiler compileString:sourceCode];
|
||||
retval = [script executeInEnvironment:env];
|
||||
|
||||
RELEASE(compiler);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@end
|
3
Languages/Smalltalk/SmalltalkInfo.plist
Normal file
3
Languages/Smalltalk/SmalltalkInfo.plist
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
STFileTypes = ( "st", "stalk" );
|
||||
}
|
460
Modules/AppKit/AppKitConstants.list
Normal file
460
Modules/AppKit/AppKitConstants.list
Normal file
|
@ -0,0 +1,460 @@
|
|||
# AppKit Constants
|
||||
#
|
||||
|
||||
# id NSApp
|
||||
|
||||
id NSModalPanelRunLoopMode
|
||||
id NSEventTrackingRunLoopMode
|
||||
|
||||
id NSFontAttributeName
|
||||
id NSParagraphStyleAttributeName
|
||||
id NSForegroundColorAttributeName
|
||||
id NSUnderlineStyleAttributeName
|
||||
id NSSuperscriptAttributeName
|
||||
id NSBackgroundColorAttributeName
|
||||
id NSAttachmentAttributeName
|
||||
id NSLigatureAttributeName
|
||||
id NSBaselineOffsetAttributeName
|
||||
id NSKernAttributeName
|
||||
id NSLinkAttributeName
|
||||
|
||||
id NSDataLinkFileNameExtension
|
||||
|
||||
id NSAFMAscender
|
||||
id NSAFMCapHeight
|
||||
id NSAFMCharacterSet
|
||||
id NSAFMDescender
|
||||
id NSAFMEncodingScheme
|
||||
id NSAFMFamilyName
|
||||
id NSAFMFontName
|
||||
id NSAFMFormatVersion
|
||||
id NSAFMFullName
|
||||
id NSAFMItalicAngle
|
||||
id NSAFMMappingScheme
|
||||
id NSAFMNotice
|
||||
id NSAFMUnderlinePosition
|
||||
id NSAFMUnderlineThickness
|
||||
id NSAFMVersion
|
||||
id NSAFMWeight
|
||||
id NSAFMXHeight
|
||||
|
||||
id NSCalibratedWhiteColorSpace
|
||||
id NSCalibratedBlackColorSpace
|
||||
id NSCalibratedRGBColorSpace
|
||||
id NSDeviceWhiteColorSpace
|
||||
id NSDeviceBlackColorSpace
|
||||
id NSDeviceRGBColorSpace
|
||||
id NSDeviceCMYKColorSpace
|
||||
id NSNamedColorSpace
|
||||
id NSCustomColorSpace
|
||||
|
||||
int NSDefaultDepth
|
||||
int NSTwoBitGrayDepth
|
||||
int NSEightBitGrayDepth
|
||||
int NSEightBitRGBDepth
|
||||
int NSTwelveBitRGBDepth
|
||||
int GSSixteenBitRGBDepth
|
||||
int NSTwentyFourBitRGBDepth
|
||||
|
||||
float NSBlack
|
||||
float NSDarkGray
|
||||
float NSWhite
|
||||
float NSLightGray
|
||||
float NSGray
|
||||
|
||||
id NSDeviceResolution
|
||||
id NSDeviceColorSpaceName
|
||||
id NSDeviceBitsPerSample
|
||||
id NSDeviceIsScreen
|
||||
id NSDeviceIsPrinter
|
||||
id NSDeviceSize
|
||||
id NSInterfaceStyleDefault
|
||||
|
||||
id NSColorPboardType
|
||||
id NSFileContentsPboardType
|
||||
id NSFilenamesPboardType
|
||||
id NSFontPboardType
|
||||
id NSRulerPboardType
|
||||
id NSPostScriptPboardType
|
||||
id NSTabularTextPboardType
|
||||
id NSRTFPboardType
|
||||
id NSRTFDPboardType
|
||||
id NSTIFFPboardType
|
||||
id NSDataLinkPboardType
|
||||
id NSGeneralPboardType
|
||||
id NSDragPboard
|
||||
id NSFindPboard
|
||||
id NSFontPboard
|
||||
id NSGeneralPboard
|
||||
id NSRulerPboard
|
||||
|
||||
id NSPrintAllPages
|
||||
id NSPrintBottomMargin
|
||||
id NSPrintCopies
|
||||
id NSPrintFaxCoverSheetName
|
||||
id NSPrintFaxHighResolution
|
||||
id NSPrintFaxModem
|
||||
id NSPrintFaxReceiverNames
|
||||
id NSPrintFaxReceiverNumbers
|
||||
id NSPrintFaxReturnReceipt
|
||||
id NSPrintFaxSendTime
|
||||
id NSPrintFaxTrimPageEnds
|
||||
id NSPrintFaxUseCoverSheet
|
||||
id NSPrintFirstPage
|
||||
id NSPrintHorizontalPagination
|
||||
id NSPrintHorizontallyCentered
|
||||
id NSPrintJobDisposition
|
||||
id NSPrintJobFeatures
|
||||
id NSPrintLastPage
|
||||
id NSPrintLeftMargin
|
||||
id NSPrintManualFeed
|
||||
id NSPrintOrientation
|
||||
id NSPrintPagesPerSheet
|
||||
id NSPrintPaperFeed
|
||||
id NSPrintPaperName
|
||||
id NSPrintPaperSize
|
||||
id NSPrintPrinter
|
||||
id NSPrintReversePageOrder
|
||||
id NSPrintRightMargin
|
||||
id NSPrintSavePath
|
||||
id NSPrintScalingFactor
|
||||
id NSPrintTopMargin
|
||||
id NSPrintVerticalPagination
|
||||
id NSPrintVerticallyCentered
|
||||
id NSPrintCancelJob
|
||||
id NSPrintFaxJob
|
||||
id NSPrintPreviewJob
|
||||
id NSPrintSaveJob
|
||||
id NSPrintSpoolJob
|
||||
id NSOldSelectedCharacterRange
|
||||
|
||||
# FIXME:
|
||||
|
||||
# NSSize NSIconSize
|
||||
# NSSize NSTokenSize
|
||||
|
||||
id NSPlainFileType
|
||||
id NSDirectoryFileType
|
||||
id NSApplicationFileType
|
||||
id NSFilesystemFileType
|
||||
id NSShellCommandFileType
|
||||
id NSWorkspaceCompressOperation
|
||||
id NSWorkspaceCopyOperation
|
||||
id NSWorkspaceDecompressOperation
|
||||
id NSWorkspaceDecryptOperation
|
||||
id NSWorkspaceDestroyOperation
|
||||
id NSWorkspaceDuplicateOperation
|
||||
id NSWorkspaceEncryptOperation
|
||||
id NSWorkspaceLinkOperation
|
||||
id NSWorkspaceMoveOperation
|
||||
id NSWorkspaceRecycleOperation
|
||||
|
||||
int NSRunStoppedResponse
|
||||
int NSRunAbortedResponse
|
||||
int NSRunContinuesResponse
|
||||
|
||||
int GSNoUnderlineStyle
|
||||
int NSSingleUnderlineStyle
|
||||
|
||||
int NSButtLineCapStyle
|
||||
int NSRoundLineCapStyle
|
||||
int NSSquareLineCapStyle
|
||||
|
||||
int NSMiterLineJoinStyle
|
||||
int NSRoundLineJoinStyle
|
||||
int NSBevelLineJoinStyle
|
||||
|
||||
int NSNonZeroWindingRule
|
||||
int NSEvenOddWindingRule
|
||||
int NSMoveToBezierPathElement
|
||||
int NSLineToBezierPathElement
|
||||
int NSCurveToBezierPathElement
|
||||
int NSClosePathBezierPathElement
|
||||
|
||||
int NSNoTitle
|
||||
int NSAboveTop
|
||||
int NSAtTop
|
||||
int NSBelowTop
|
||||
int NSAboveBottom
|
||||
int NSAtBottom
|
||||
int NSBelowBottom
|
||||
|
||||
int NSTIFFCompressionNone
|
||||
int NSTIFFCompressionCCITTFAX3
|
||||
int NSTIFFCompressionCCITTFAX4
|
||||
int NSTIFFCompressionLZW
|
||||
int NSTIFFCompressionJPEG
|
||||
int NSTIFFCompressionNEXT
|
||||
int NSTIFFCompressionPackBits
|
||||
int NSTIFFCompressionOldJPEG
|
||||
|
||||
int NSTIFFFileType
|
||||
int NSBMPFileType
|
||||
int NSGIFFileType
|
||||
int NSJPEGFileType
|
||||
int NSPNGFileType
|
||||
|
||||
int NSMomentaryPushButton
|
||||
int NSPushOnPushOffButton
|
||||
int NSToggleButton
|
||||
int NSSwitchButton
|
||||
int NSRadioButton
|
||||
int NSMomentaryChangeButton
|
||||
int NSOnOffButton
|
||||
int NSMomentaryLight
|
||||
|
||||
int NSRoundedBezelStyle
|
||||
int NSRegularSquareBezelStyle
|
||||
int NSThickSquareBezelStyle
|
||||
int NSThickerSquareBezelStyle
|
||||
int NSNeXTBezelStyle
|
||||
int NSPushButtonBezelStyle
|
||||
int NSSmallIconButtonBezelStyle
|
||||
int NSMediumIconButtonBezelStyle
|
||||
int NSLargeIconButtonBezelStyle
|
||||
|
||||
int NSGradientNone
|
||||
int NSGradientConcaveWeak
|
||||
int NSGradientConcaveStrong
|
||||
int NSGradientConvexWeak
|
||||
int NSGradientConvexStrong
|
||||
|
||||
# int NSLeftAlignedParagraph
|
||||
# int NSRightAlignedParagraph
|
||||
# int NSCenterAlignedParagraph
|
||||
# int NSJustificationAlignedParagraph
|
||||
# int NSFirstIndentParagraph
|
||||
# int NSIndentParagraph
|
||||
# int NSAddTabParagraph
|
||||
# int NSRemoveTabParagraph
|
||||
# int NSLeftMarginParagraph
|
||||
# int NSRightMarginParagraph
|
||||
|
||||
# int NSTextBlockSize
|
||||
|
||||
int NSNullCellType
|
||||
int NSTextCellType
|
||||
int NSImageCellType
|
||||
|
||||
int NSAnyType
|
||||
int NSIntType
|
||||
int NSPositiveIntType
|
||||
int NSFloatType
|
||||
int NSPositiveFloatType
|
||||
int NSDateType
|
||||
int NSDoubleType
|
||||
int NSPositiveDoubleType
|
||||
|
||||
int NSNoImage
|
||||
int NSImageOnly
|
||||
int NSImageLeft
|
||||
int NSImageRight
|
||||
int NSImageBelow
|
||||
int NSImageAbove
|
||||
int NSImageOverlaps
|
||||
|
||||
int NSCellDisabled
|
||||
int NSCellState
|
||||
int NSPushInCell
|
||||
int NSCellEditable
|
||||
int NSChangeGrayCell
|
||||
int NSCellHighlighted
|
||||
int NSCellLightsByContents
|
||||
int NSCellLightsByGray
|
||||
int NSChangeBackgroundCell
|
||||
int NSCellLightsByBackground
|
||||
int NSCellIsBordered
|
||||
int NSCellHasOverlappingImage
|
||||
int NSCellHasImageHorizontal
|
||||
int NSCellHasImageOnLeftOrBottom
|
||||
int NSCellChangesContents
|
||||
int NSCellIsInsetButton
|
||||
int NSCellAllowsMixedState
|
||||
|
||||
int NSNoCellMask
|
||||
int NSContentsCellMask
|
||||
int NSPushInCellMask
|
||||
int NSChangeGrayCellMask
|
||||
int NSChangeBackgroundCellMask
|
||||
int NSOffState
|
||||
int NSOnState
|
||||
int NSMixedState
|
||||
|
||||
int NSDefaultControlTint
|
||||
int NSClearControlTint
|
||||
|
||||
int NSGrayModeColorPanel
|
||||
int NSRGBModeColorPanel
|
||||
int NSCMYKModeColorPanel
|
||||
int NSHSBModeColorPanel
|
||||
int NSCustomPaletteModeColorPanel
|
||||
int NSColorListModeColorPanel
|
||||
int NSWheelModeColorPanel
|
||||
|
||||
int NSColorPanelGrayModeMask
|
||||
int NSColorPanelRGBModeMask
|
||||
int NSColorPanelCMYKModeMask
|
||||
int NSColorPanelHSBModeMask
|
||||
int NSColorPanelCustomPaletteModeMask
|
||||
int NSColorPanelColorListModeMask
|
||||
int NSColorPanelWheelModeMask
|
||||
int NSColorPanelAllModesMask
|
||||
|
||||
# GSCursorTypes
|
||||
int GSArrowCursor
|
||||
int GSIBeamCursor
|
||||
|
||||
# NSDataLinkDisposition
|
||||
int NSLinkInDestination
|
||||
int NSLinkInSource
|
||||
int NSLinkBroken
|
||||
|
||||
# NSDataLinkUpdateMode
|
||||
int NSUpdateContinuously
|
||||
int NSUpdateWhenSourceSaved
|
||||
int NSUpdateManually
|
||||
int NSUpdateNever
|
||||
|
||||
int NSChangeDone
|
||||
int NSChangeUndone
|
||||
int NSChangeCleared
|
||||
|
||||
int NSSaveOperation
|
||||
int NSSaveAsOperation
|
||||
int NSSaveToOperation
|
||||
|
||||
int NSDragOperationNone
|
||||
int NSDragOperationCopy
|
||||
int NSDragOperationLink
|
||||
int NSDragOperationGeneric
|
||||
int NSDragOperationPrivate
|
||||
int NSDragOperationAll
|
||||
|
||||
# GSFileWrapperType
|
||||
|
||||
int GSFileWrapperDirectoryType
|
||||
int GSFileWrapperRegularFileType
|
||||
int GSFileWrapperSymbolicLinkType
|
||||
|
||||
int NSControlGlyph
|
||||
int NSNullGlyph
|
||||
|
||||
# NSGlyphRelation
|
||||
|
||||
int NSGlyphBelow
|
||||
int NSGlyphAbove
|
||||
|
||||
# NSMultibyteGlyphPacking
|
||||
int NSOneByteGlyphPacking
|
||||
int NSJapaneseEUCGlyphPacking
|
||||
int NSAsciiWithDoubleByteEUCGlyphPacking
|
||||
int NSTwoByteGlyphPacking
|
||||
int NSFourByteGlyphPacking
|
||||
|
||||
int NSItalicFontMask
|
||||
int NSUnitalicFontMask
|
||||
int NSBoldFontMask
|
||||
int NSUnboldFontMask
|
||||
int NSNarrowFontMask
|
||||
int NSExpandedFontMask
|
||||
int NSCondensedFontMask
|
||||
int NSSmallCapsFontMask
|
||||
int NSPosterFontMask
|
||||
int NSCompressedFontMask
|
||||
int NSNonStandardCharacterSetFontMask
|
||||
int NSFixedPitchFontMask
|
||||
|
||||
# NSFontTag
|
||||
|
||||
int NSNoFontChangeAction
|
||||
int NSViaPanelFontAction
|
||||
int NSAddTraitFontAction
|
||||
int NSRemoveTraitFontAction
|
||||
int NSSizeUpFontAction
|
||||
int NSSizeDownFontAction
|
||||
int NSHeavierFontAction
|
||||
int NSLighterFontAction
|
||||
|
||||
int NSFPPreviewButton
|
||||
int NSFPRevertButton
|
||||
int NSFPSetButton
|
||||
int NSFPPreviewField
|
||||
int NSFPSizeField
|
||||
int NSFPSizeTitle
|
||||
int NSFPCurrentField
|
||||
|
||||
int NSFPFamilyBrowser
|
||||
int NSFPFaceBrowser
|
||||
int NSFPSizeBrowser
|
||||
|
||||
# NSBackingStoreType
|
||||
|
||||
int NSBackingStoreRetained
|
||||
int NSBackingStoreNonretained
|
||||
int NSBackingStoreBuffered
|
||||
|
||||
|
||||
# NSCompositingOperation
|
||||
|
||||
int NSCompositeClear
|
||||
int NSCompositeCopy
|
||||
int NSCompositeSourceOver
|
||||
int NSCompositeSourceIn
|
||||
int NSCompositeSourceOut
|
||||
int NSCompositeSourceAtop
|
||||
int NSCompositeDestinationOver
|
||||
int NSCompositeDestinationIn
|
||||
int NSCompositeDestinationOut
|
||||
int NSCompositeDestinationAtop
|
||||
int NSCompositeXOR
|
||||
int NSCompositePlusDarker
|
||||
int NSCompositeHighlight
|
||||
int NSCompositePlusLighter
|
||||
|
||||
# NSWindowOrderingMode
|
||||
|
||||
int NSWindowAbove
|
||||
int NSWindowBelow
|
||||
int NSWindowOut
|
||||
|
||||
# GSWindowInputState
|
||||
int GSTitleBarKey
|
||||
int GSTitleBarNormal
|
||||
int GSTitleBarMain
|
||||
|
||||
# NSImageScaling
|
||||
int NSScaleProportionally
|
||||
int NSScaleToFit
|
||||
int NSScaleNone
|
||||
|
||||
# NSImageAlignment
|
||||
int NSImageAlignCenter
|
||||
int NSImageAlignTop
|
||||
int NSImageAlignTopLeft
|
||||
int NSImageAlignTopRight
|
||||
int NSImageAlignLeft
|
||||
int NSImageAlignBottom
|
||||
int NSImageAlignBottomLeft
|
||||
int NSImageAlignBottomRight
|
||||
int NSImageAlignRight
|
||||
|
||||
# NSImageFrameStyle
|
||||
|
||||
int NSImageFrameNone
|
||||
int NSImageFramePhoto
|
||||
int NSImageFrameGrayBezel
|
||||
int NSImageFrameGroove
|
||||
int NSImageFrameButton
|
||||
|
||||
# NSPanel
|
||||
|
||||
int NSUtilityWindowMask
|
||||
int NSDocModalWindowMask
|
||||
int NSOKButton
|
||||
int NSCancelButton
|
||||
|
||||
int NSAlertDefaultReturn
|
||||
int NSAlertAlternateReturn
|
||||
int NSAlertOtherReturn
|
||||
int NSAlertErrorReturn
|
||||
|
430
Modules/AppKit/AppKitConstants.m
Normal file
430
Modules/AppKit/AppKitConstants.m
Normal file
|
@ -0,0 +1,430 @@
|
|||
/**
|
||||
AppKitConstants.m
|
||||
|
||||
NOTE: Do not edit this file, it is automaticaly generated.
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
This file is part of the StepTalk project.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <AppKit/AppKitExceptions.h>
|
||||
|
||||
#import <AppKit/NSDocument.h>
|
||||
#import <AppKit/NSHelpManager.h>
|
||||
|
||||
|
||||
NSDictionary *STGetAppKitConstants(void)
|
||||
{
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
Class numberClass = [NSNumber class];
|
||||
IMP numberWithInt;
|
||||
IMP numberWithFloat;
|
||||
IMP setObject_forKey;
|
||||
|
||||
SEL numberWithInt_sel = @selector(numberWithInt:);
|
||||
SEL numberWithFloat_sel = @selector(numberWithFloat:);
|
||||
SEL setObject_forKey_sel = @selector(setObject:forKey:);
|
||||
|
||||
numberWithInt = [NSNumber methodForSelector:numberWithInt_sel];
|
||||
numberWithFloat = [NSNumber methodForSelector:numberWithFloat_sel];
|
||||
setObject_forKey = [dict methodForSelector:setObject_forKey_sel];
|
||||
|
||||
#define ADD_id_OBJECT(obj, name) \
|
||||
setObject_forKey(dict, setObject_forKey_sel, obj, name)
|
||||
|
||||
#define ADD_int_OBJECT(obj, name) \
|
||||
setObject_forKey(dict, setObject_forKey_sel, \
|
||||
numberWithInt(numberClass, numberWithInt_sel, obj), \
|
||||
name)
|
||||
|
||||
#define ADD_float_OBJECT(obj, name) \
|
||||
setObject_forKey(dict, setObject_forKey_sel, \
|
||||
numberWithFloat(numberClass, numberWithInt_sel, obj), \
|
||||
name)
|
||||
|
||||
ADD_id_OBJECT(NSModalPanelRunLoopMode,@"NSModalPanelRunLoopMode");
|
||||
ADD_id_OBJECT(NSEventTrackingRunLoopMode,@"NSEventTrackingRunLoopMode");
|
||||
ADD_id_OBJECT(NSFontAttributeName,@"NSFontAttributeName");
|
||||
ADD_id_OBJECT(NSParagraphStyleAttributeName,@"NSParagraphStyleAttributeName");
|
||||
ADD_id_OBJECT(NSForegroundColorAttributeName,@"NSForegroundColorAttributeName");
|
||||
ADD_id_OBJECT(NSUnderlineStyleAttributeName,@"NSUnderlineStyleAttributeName");
|
||||
ADD_id_OBJECT(NSSuperscriptAttributeName,@"NSSuperscriptAttributeName");
|
||||
ADD_id_OBJECT(NSBackgroundColorAttributeName,@"NSBackgroundColorAttributeName");
|
||||
ADD_id_OBJECT(NSAttachmentAttributeName,@"NSAttachmentAttributeName");
|
||||
ADD_id_OBJECT(NSLigatureAttributeName,@"NSLigatureAttributeName");
|
||||
ADD_id_OBJECT(NSBaselineOffsetAttributeName,@"NSBaselineOffsetAttributeName");
|
||||
ADD_id_OBJECT(NSKernAttributeName,@"NSKernAttributeName");
|
||||
ADD_id_OBJECT(NSLinkAttributeName,@"NSLinkAttributeName");
|
||||
ADD_id_OBJECT(NSDataLinkFileNameExtension,@"NSDataLinkFileNameExtension");
|
||||
ADD_id_OBJECT(NSAFMAscender,@"NSAFMAscender");
|
||||
ADD_id_OBJECT(NSAFMCapHeight,@"NSAFMCapHeight");
|
||||
ADD_id_OBJECT(NSAFMCharacterSet,@"NSAFMCharacterSet");
|
||||
ADD_id_OBJECT(NSAFMDescender,@"NSAFMDescender");
|
||||
ADD_id_OBJECT(NSAFMEncodingScheme,@"NSAFMEncodingScheme");
|
||||
ADD_id_OBJECT(NSAFMFamilyName,@"NSAFMFamilyName");
|
||||
ADD_id_OBJECT(NSAFMFontName,@"NSAFMFontName");
|
||||
ADD_id_OBJECT(NSAFMFormatVersion,@"NSAFMFormatVersion");
|
||||
ADD_id_OBJECT(NSAFMFullName,@"NSAFMFullName");
|
||||
ADD_id_OBJECT(NSAFMItalicAngle,@"NSAFMItalicAngle");
|
||||
ADD_id_OBJECT(NSAFMMappingScheme,@"NSAFMMappingScheme");
|
||||
ADD_id_OBJECT(NSAFMNotice,@"NSAFMNotice");
|
||||
ADD_id_OBJECT(NSAFMUnderlinePosition,@"NSAFMUnderlinePosition");
|
||||
ADD_id_OBJECT(NSAFMUnderlineThickness,@"NSAFMUnderlineThickness");
|
||||
ADD_id_OBJECT(NSAFMVersion,@"NSAFMVersion");
|
||||
ADD_id_OBJECT(NSAFMWeight,@"NSAFMWeight");
|
||||
ADD_id_OBJECT(NSAFMXHeight,@"NSAFMXHeight");
|
||||
ADD_id_OBJECT(NSCalibratedWhiteColorSpace,@"NSCalibratedWhiteColorSpace");
|
||||
ADD_id_OBJECT(NSCalibratedBlackColorSpace,@"NSCalibratedBlackColorSpace");
|
||||
ADD_id_OBJECT(NSCalibratedRGBColorSpace,@"NSCalibratedRGBColorSpace");
|
||||
ADD_id_OBJECT(NSDeviceWhiteColorSpace,@"NSDeviceWhiteColorSpace");
|
||||
ADD_id_OBJECT(NSDeviceBlackColorSpace,@"NSDeviceBlackColorSpace");
|
||||
ADD_id_OBJECT(NSDeviceRGBColorSpace,@"NSDeviceRGBColorSpace");
|
||||
ADD_id_OBJECT(NSDeviceCMYKColorSpace,@"NSDeviceCMYKColorSpace");
|
||||
ADD_id_OBJECT(NSNamedColorSpace,@"NSNamedColorSpace");
|
||||
ADD_id_OBJECT(NSCustomColorSpace,@"NSCustomColorSpace");
|
||||
ADD_int_OBJECT(NSDefaultDepth,@"NSDefaultDepth");
|
||||
ADD_int_OBJECT(NSTwoBitGrayDepth,@"NSTwoBitGrayDepth");
|
||||
ADD_int_OBJECT(NSEightBitGrayDepth,@"NSEightBitGrayDepth");
|
||||
ADD_int_OBJECT(NSEightBitRGBDepth,@"NSEightBitRGBDepth");
|
||||
ADD_int_OBJECT(NSTwelveBitRGBDepth,@"NSTwelveBitRGBDepth");
|
||||
ADD_int_OBJECT(GSSixteenBitRGBDepth,@"GSSixteenBitRGBDepth");
|
||||
ADD_int_OBJECT(NSTwentyFourBitRGBDepth,@"NSTwentyFourBitRGBDepth");
|
||||
ADD_float_OBJECT(NSBlack,@"NSBlack");
|
||||
ADD_float_OBJECT(NSDarkGray,@"NSDarkGray");
|
||||
ADD_float_OBJECT(NSWhite,@"NSWhite");
|
||||
ADD_float_OBJECT(NSLightGray,@"NSLightGray");
|
||||
ADD_float_OBJECT(NSGray,@"NSGray");
|
||||
ADD_id_OBJECT(NSDeviceResolution,@"NSDeviceResolution");
|
||||
ADD_id_OBJECT(NSDeviceColorSpaceName,@"NSDeviceColorSpaceName");
|
||||
ADD_id_OBJECT(NSDeviceBitsPerSample,@"NSDeviceBitsPerSample");
|
||||
ADD_id_OBJECT(NSDeviceIsScreen,@"NSDeviceIsScreen");
|
||||
ADD_id_OBJECT(NSDeviceIsPrinter,@"NSDeviceIsPrinter");
|
||||
ADD_id_OBJECT(NSDeviceSize,@"NSDeviceSize");
|
||||
ADD_id_OBJECT(NSInterfaceStyleDefault,@"NSInterfaceStyleDefault");
|
||||
ADD_id_OBJECT(NSColorPboardType,@"NSColorPboardType");
|
||||
ADD_id_OBJECT(NSFileContentsPboardType,@"NSFileContentsPboardType");
|
||||
ADD_id_OBJECT(NSFilenamesPboardType,@"NSFilenamesPboardType");
|
||||
ADD_id_OBJECT(NSFontPboardType,@"NSFontPboardType");
|
||||
ADD_id_OBJECT(NSRulerPboardType,@"NSRulerPboardType");
|
||||
ADD_id_OBJECT(NSPostScriptPboardType,@"NSPostScriptPboardType");
|
||||
ADD_id_OBJECT(NSTabularTextPboardType,@"NSTabularTextPboardType");
|
||||
ADD_id_OBJECT(NSRTFPboardType,@"NSRTFPboardType");
|
||||
ADD_id_OBJECT(NSRTFDPboardType,@"NSRTFDPboardType");
|
||||
ADD_id_OBJECT(NSTIFFPboardType,@"NSTIFFPboardType");
|
||||
ADD_id_OBJECT(NSDataLinkPboardType,@"NSDataLinkPboardType");
|
||||
ADD_id_OBJECT(NSGeneralPboardType,@"NSGeneralPboardType");
|
||||
ADD_id_OBJECT(NSDragPboard,@"NSDragPboard");
|
||||
ADD_id_OBJECT(NSFindPboard,@"NSFindPboard");
|
||||
ADD_id_OBJECT(NSFontPboard,@"NSFontPboard");
|
||||
ADD_id_OBJECT(NSGeneralPboard,@"NSGeneralPboard");
|
||||
ADD_id_OBJECT(NSRulerPboard,@"NSRulerPboard");
|
||||
ADD_id_OBJECT(NSPrintAllPages,@"NSPrintAllPages");
|
||||
ADD_id_OBJECT(NSPrintBottomMargin,@"NSPrintBottomMargin");
|
||||
ADD_id_OBJECT(NSPrintCopies,@"NSPrintCopies");
|
||||
ADD_id_OBJECT(NSPrintFaxCoverSheetName,@"NSPrintFaxCoverSheetName");
|
||||
ADD_id_OBJECT(NSPrintFaxHighResolution,@"NSPrintFaxHighResolution");
|
||||
ADD_id_OBJECT(NSPrintFaxModem,@"NSPrintFaxModem");
|
||||
ADD_id_OBJECT(NSPrintFaxReceiverNames,@"NSPrintFaxReceiverNames");
|
||||
ADD_id_OBJECT(NSPrintFaxReceiverNumbers,@"NSPrintFaxReceiverNumbers");
|
||||
ADD_id_OBJECT(NSPrintFaxReturnReceipt,@"NSPrintFaxReturnReceipt");
|
||||
ADD_id_OBJECT(NSPrintFaxSendTime,@"NSPrintFaxSendTime");
|
||||
ADD_id_OBJECT(NSPrintFaxTrimPageEnds,@"NSPrintFaxTrimPageEnds");
|
||||
ADD_id_OBJECT(NSPrintFaxUseCoverSheet,@"NSPrintFaxUseCoverSheet");
|
||||
ADD_id_OBJECT(NSPrintFirstPage,@"NSPrintFirstPage");
|
||||
ADD_id_OBJECT(NSPrintHorizontalPagination,@"NSPrintHorizontalPagination");
|
||||
ADD_id_OBJECT(NSPrintHorizontallyCentered,@"NSPrintHorizontallyCentered");
|
||||
ADD_id_OBJECT(NSPrintJobDisposition,@"NSPrintJobDisposition");
|
||||
ADD_id_OBJECT(NSPrintJobFeatures,@"NSPrintJobFeatures");
|
||||
ADD_id_OBJECT(NSPrintLastPage,@"NSPrintLastPage");
|
||||
ADD_id_OBJECT(NSPrintLeftMargin,@"NSPrintLeftMargin");
|
||||
ADD_id_OBJECT(NSPrintManualFeed,@"NSPrintManualFeed");
|
||||
ADD_id_OBJECT(NSPrintOrientation,@"NSPrintOrientation");
|
||||
ADD_id_OBJECT(NSPrintPagesPerSheet,@"NSPrintPagesPerSheet");
|
||||
ADD_id_OBJECT(NSPrintPaperFeed,@"NSPrintPaperFeed");
|
||||
ADD_id_OBJECT(NSPrintPaperName,@"NSPrintPaperName");
|
||||
ADD_id_OBJECT(NSPrintPaperSize,@"NSPrintPaperSize");
|
||||
ADD_id_OBJECT(NSPrintPrinter,@"NSPrintPrinter");
|
||||
ADD_id_OBJECT(NSPrintReversePageOrder,@"NSPrintReversePageOrder");
|
||||
ADD_id_OBJECT(NSPrintRightMargin,@"NSPrintRightMargin");
|
||||
ADD_id_OBJECT(NSPrintSavePath,@"NSPrintSavePath");
|
||||
ADD_id_OBJECT(NSPrintScalingFactor,@"NSPrintScalingFactor");
|
||||
ADD_id_OBJECT(NSPrintTopMargin,@"NSPrintTopMargin");
|
||||
ADD_id_OBJECT(NSPrintVerticalPagination,@"NSPrintVerticalPagination");
|
||||
ADD_id_OBJECT(NSPrintVerticallyCentered,@"NSPrintVerticallyCentered");
|
||||
ADD_id_OBJECT(NSPrintCancelJob,@"NSPrintCancelJob");
|
||||
ADD_id_OBJECT(NSPrintFaxJob,@"NSPrintFaxJob");
|
||||
ADD_id_OBJECT(NSPrintPreviewJob,@"NSPrintPreviewJob");
|
||||
ADD_id_OBJECT(NSPrintSaveJob,@"NSPrintSaveJob");
|
||||
ADD_id_OBJECT(NSPrintSpoolJob,@"NSPrintSpoolJob");
|
||||
ADD_id_OBJECT(NSOldSelectedCharacterRange,@"NSOldSelectedCharacterRange");
|
||||
ADD_id_OBJECT(NSPlainFileType,@"NSPlainFileType");
|
||||
ADD_id_OBJECT(NSDirectoryFileType,@"NSDirectoryFileType");
|
||||
ADD_id_OBJECT(NSApplicationFileType,@"NSApplicationFileType");
|
||||
ADD_id_OBJECT(NSFilesystemFileType,@"NSFilesystemFileType");
|
||||
ADD_id_OBJECT(NSShellCommandFileType,@"NSShellCommandFileType");
|
||||
ADD_id_OBJECT(NSWorkspaceCompressOperation,@"NSWorkspaceCompressOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceCopyOperation,@"NSWorkspaceCopyOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceDecompressOperation,@"NSWorkspaceDecompressOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceDecryptOperation,@"NSWorkspaceDecryptOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceDestroyOperation,@"NSWorkspaceDestroyOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceDuplicateOperation,@"NSWorkspaceDuplicateOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceEncryptOperation,@"NSWorkspaceEncryptOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceLinkOperation,@"NSWorkspaceLinkOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceMoveOperation,@"NSWorkspaceMoveOperation");
|
||||
ADD_id_OBJECT(NSWorkspaceRecycleOperation,@"NSWorkspaceRecycleOperation");
|
||||
ADD_int_OBJECT(NSRunStoppedResponse,@"NSRunStoppedResponse");
|
||||
ADD_int_OBJECT(NSRunAbortedResponse,@"NSRunAbortedResponse");
|
||||
ADD_int_OBJECT(NSRunContinuesResponse,@"NSRunContinuesResponse");
|
||||
ADD_int_OBJECT(GSNoUnderlineStyle,@"GSNoUnderlineStyle");
|
||||
ADD_int_OBJECT(NSSingleUnderlineStyle,@"NSSingleUnderlineStyle");
|
||||
ADD_int_OBJECT(NSButtLineCapStyle,@"NSButtLineCapStyle");
|
||||
ADD_int_OBJECT(NSRoundLineCapStyle,@"NSRoundLineCapStyle");
|
||||
ADD_int_OBJECT(NSSquareLineCapStyle,@"NSSquareLineCapStyle");
|
||||
ADD_int_OBJECT(NSMiterLineJoinStyle,@"NSMiterLineJoinStyle");
|
||||
ADD_int_OBJECT(NSRoundLineJoinStyle,@"NSRoundLineJoinStyle");
|
||||
ADD_int_OBJECT(NSBevelLineJoinStyle,@"NSBevelLineJoinStyle");
|
||||
ADD_int_OBJECT(NSNonZeroWindingRule,@"NSNonZeroWindingRule");
|
||||
ADD_int_OBJECT(NSEvenOddWindingRule,@"NSEvenOddWindingRule");
|
||||
ADD_int_OBJECT(NSMoveToBezierPathElement,@"NSMoveToBezierPathElement");
|
||||
ADD_int_OBJECT(NSLineToBezierPathElement,@"NSLineToBezierPathElement");
|
||||
ADD_int_OBJECT(NSCurveToBezierPathElement,@"NSCurveToBezierPathElement");
|
||||
ADD_int_OBJECT(NSClosePathBezierPathElement,@"NSClosePathBezierPathElement");
|
||||
ADD_int_OBJECT(NSNoTitle,@"NSNoTitle");
|
||||
ADD_int_OBJECT(NSAboveTop,@"NSAboveTop");
|
||||
ADD_int_OBJECT(NSAtTop,@"NSAtTop");
|
||||
ADD_int_OBJECT(NSBelowTop,@"NSBelowTop");
|
||||
ADD_int_OBJECT(NSAboveBottom,@"NSAboveBottom");
|
||||
ADD_int_OBJECT(NSAtBottom,@"NSAtBottom");
|
||||
ADD_int_OBJECT(NSBelowBottom,@"NSBelowBottom");
|
||||
ADD_int_OBJECT(NSTIFFCompressionNone,@"NSTIFFCompressionNone");
|
||||
ADD_int_OBJECT(NSTIFFCompressionCCITTFAX3,@"NSTIFFCompressionCCITTFAX3");
|
||||
ADD_int_OBJECT(NSTIFFCompressionCCITTFAX4,@"NSTIFFCompressionCCITTFAX4");
|
||||
ADD_int_OBJECT(NSTIFFCompressionLZW,@"NSTIFFCompressionLZW");
|
||||
ADD_int_OBJECT(NSTIFFCompressionJPEG,@"NSTIFFCompressionJPEG");
|
||||
ADD_int_OBJECT(NSTIFFCompressionNEXT,@"NSTIFFCompressionNEXT");
|
||||
ADD_int_OBJECT(NSTIFFCompressionPackBits,@"NSTIFFCompressionPackBits");
|
||||
ADD_int_OBJECT(NSTIFFCompressionOldJPEG,@"NSTIFFCompressionOldJPEG");
|
||||
ADD_int_OBJECT(NSTIFFFileType,@"NSTIFFFileType");
|
||||
ADD_int_OBJECT(NSBMPFileType,@"NSBMPFileType");
|
||||
ADD_int_OBJECT(NSGIFFileType,@"NSGIFFileType");
|
||||
ADD_int_OBJECT(NSJPEGFileType,@"NSJPEGFileType");
|
||||
ADD_int_OBJECT(NSPNGFileType,@"NSPNGFileType");
|
||||
ADD_int_OBJECT(NSMomentaryPushButton,@"NSMomentaryPushButton");
|
||||
ADD_int_OBJECT(NSPushOnPushOffButton,@"NSPushOnPushOffButton");
|
||||
ADD_int_OBJECT(NSToggleButton,@"NSToggleButton");
|
||||
ADD_int_OBJECT(NSSwitchButton,@"NSSwitchButton");
|
||||
ADD_int_OBJECT(NSRadioButton,@"NSRadioButton");
|
||||
ADD_int_OBJECT(NSMomentaryChangeButton,@"NSMomentaryChangeButton");
|
||||
ADD_int_OBJECT(NSOnOffButton,@"NSOnOffButton");
|
||||
ADD_int_OBJECT(NSMomentaryLight,@"NSMomentaryLight");
|
||||
ADD_int_OBJECT(NSRoundedBezelStyle,@"NSRoundedBezelStyle");
|
||||
ADD_int_OBJECT(NSRegularSquareBezelStyle,@"NSRegularSquareBezelStyle");
|
||||
ADD_int_OBJECT(NSThickSquareBezelStyle,@"NSThickSquareBezelStyle");
|
||||
ADD_int_OBJECT(NSThickerSquareBezelStyle,@"NSThickerSquareBezelStyle");
|
||||
ADD_int_OBJECT(NSNeXTBezelStyle,@"NSNeXTBezelStyle");
|
||||
ADD_int_OBJECT(NSPushButtonBezelStyle,@"NSPushButtonBezelStyle");
|
||||
ADD_int_OBJECT(NSSmallIconButtonBezelStyle,@"NSSmallIconButtonBezelStyle");
|
||||
ADD_int_OBJECT(NSMediumIconButtonBezelStyle,@"NSMediumIconButtonBezelStyle");
|
||||
ADD_int_OBJECT(NSLargeIconButtonBezelStyle,@"NSLargeIconButtonBezelStyle");
|
||||
ADD_int_OBJECT(NSGradientNone,@"NSGradientNone");
|
||||
ADD_int_OBJECT(NSGradientConcaveWeak,@"NSGradientConcaveWeak");
|
||||
ADD_int_OBJECT(NSGradientConcaveStrong,@"NSGradientConcaveStrong");
|
||||
ADD_int_OBJECT(NSGradientConvexWeak,@"NSGradientConvexWeak");
|
||||
ADD_int_OBJECT(NSGradientConvexStrong,@"NSGradientConvexStrong");
|
||||
ADD_int_OBJECT(NSNullCellType,@"NSNullCellType");
|
||||
ADD_int_OBJECT(NSTextCellType,@"NSTextCellType");
|
||||
ADD_int_OBJECT(NSImageCellType,@"NSImageCellType");
|
||||
ADD_int_OBJECT(NSAnyType,@"NSAnyType");
|
||||
ADD_int_OBJECT(NSIntType,@"NSIntType");
|
||||
ADD_int_OBJECT(NSPositiveIntType,@"NSPositiveIntType");
|
||||
ADD_int_OBJECT(NSFloatType,@"NSFloatType");
|
||||
ADD_int_OBJECT(NSPositiveFloatType,@"NSPositiveFloatType");
|
||||
ADD_int_OBJECT(NSDateType,@"NSDateType");
|
||||
ADD_int_OBJECT(NSDoubleType,@"NSDoubleType");
|
||||
ADD_int_OBJECT(NSPositiveDoubleType,@"NSPositiveDoubleType");
|
||||
ADD_int_OBJECT(NSNoImage,@"NSNoImage");
|
||||
ADD_int_OBJECT(NSImageOnly,@"NSImageOnly");
|
||||
ADD_int_OBJECT(NSImageLeft,@"NSImageLeft");
|
||||
ADD_int_OBJECT(NSImageRight,@"NSImageRight");
|
||||
ADD_int_OBJECT(NSImageBelow,@"NSImageBelow");
|
||||
ADD_int_OBJECT(NSImageAbove,@"NSImageAbove");
|
||||
ADD_int_OBJECT(NSImageOverlaps,@"NSImageOverlaps");
|
||||
ADD_int_OBJECT(NSCellDisabled,@"NSCellDisabled");
|
||||
ADD_int_OBJECT(NSCellState,@"NSCellState");
|
||||
ADD_int_OBJECT(NSPushInCell,@"NSPushInCell");
|
||||
ADD_int_OBJECT(NSCellEditable,@"NSCellEditable");
|
||||
ADD_int_OBJECT(NSChangeGrayCell,@"NSChangeGrayCell");
|
||||
ADD_int_OBJECT(NSCellHighlighted,@"NSCellHighlighted");
|
||||
ADD_int_OBJECT(NSCellLightsByContents,@"NSCellLightsByContents");
|
||||
ADD_int_OBJECT(NSCellLightsByGray,@"NSCellLightsByGray");
|
||||
ADD_int_OBJECT(NSChangeBackgroundCell,@"NSChangeBackgroundCell");
|
||||
ADD_int_OBJECT(NSCellLightsByBackground,@"NSCellLightsByBackground");
|
||||
ADD_int_OBJECT(NSCellIsBordered,@"NSCellIsBordered");
|
||||
ADD_int_OBJECT(NSCellHasOverlappingImage,@"NSCellHasOverlappingImage");
|
||||
ADD_int_OBJECT(NSCellHasImageHorizontal,@"NSCellHasImageHorizontal");
|
||||
ADD_int_OBJECT(NSCellHasImageOnLeftOrBottom,@"NSCellHasImageOnLeftOrBottom");
|
||||
ADD_int_OBJECT(NSCellChangesContents,@"NSCellChangesContents");
|
||||
ADD_int_OBJECT(NSCellIsInsetButton,@"NSCellIsInsetButton");
|
||||
ADD_int_OBJECT(NSCellAllowsMixedState,@"NSCellAllowsMixedState");
|
||||
ADD_int_OBJECT(NSNoCellMask,@"NSNoCellMask");
|
||||
ADD_int_OBJECT(NSContentsCellMask,@"NSContentsCellMask");
|
||||
ADD_int_OBJECT(NSPushInCellMask,@"NSPushInCellMask");
|
||||
ADD_int_OBJECT(NSChangeGrayCellMask,@"NSChangeGrayCellMask");
|
||||
ADD_int_OBJECT(NSChangeBackgroundCellMask,@"NSChangeBackgroundCellMask");
|
||||
ADD_int_OBJECT(NSOffState,@"NSOffState");
|
||||
ADD_int_OBJECT(NSOnState,@"NSOnState");
|
||||
ADD_int_OBJECT(NSMixedState,@"NSMixedState");
|
||||
ADD_int_OBJECT(NSDefaultControlTint,@"NSDefaultControlTint");
|
||||
ADD_int_OBJECT(NSClearControlTint,@"NSClearControlTint");
|
||||
ADD_int_OBJECT(NSGrayModeColorPanel,@"NSGrayModeColorPanel");
|
||||
ADD_int_OBJECT(NSRGBModeColorPanel,@"NSRGBModeColorPanel");
|
||||
ADD_int_OBJECT(NSCMYKModeColorPanel,@"NSCMYKModeColorPanel");
|
||||
ADD_int_OBJECT(NSHSBModeColorPanel,@"NSHSBModeColorPanel");
|
||||
ADD_int_OBJECT(NSCustomPaletteModeColorPanel,@"NSCustomPaletteModeColorPanel");
|
||||
ADD_int_OBJECT(NSColorListModeColorPanel,@"NSColorListModeColorPanel");
|
||||
ADD_int_OBJECT(NSWheelModeColorPanel,@"NSWheelModeColorPanel");
|
||||
ADD_int_OBJECT(NSColorPanelGrayModeMask,@"NSColorPanelGrayModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelRGBModeMask,@"NSColorPanelRGBModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelCMYKModeMask,@"NSColorPanelCMYKModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelHSBModeMask,@"NSColorPanelHSBModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelCustomPaletteModeMask,@"NSColorPanelCustomPaletteModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelColorListModeMask,@"NSColorPanelColorListModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelWheelModeMask,@"NSColorPanelWheelModeMask");
|
||||
ADD_int_OBJECT(NSColorPanelAllModesMask,@"NSColorPanelAllModesMask");
|
||||
ADD_int_OBJECT(GSArrowCursor,@"GSArrowCursor");
|
||||
ADD_int_OBJECT(GSIBeamCursor,@"GSIBeamCursor");
|
||||
ADD_int_OBJECT(NSLinkInDestination,@"NSLinkInDestination");
|
||||
ADD_int_OBJECT(NSLinkInSource,@"NSLinkInSource");
|
||||
ADD_int_OBJECT(NSLinkBroken,@"NSLinkBroken");
|
||||
ADD_int_OBJECT(NSUpdateContinuously,@"NSUpdateContinuously");
|
||||
ADD_int_OBJECT(NSUpdateWhenSourceSaved,@"NSUpdateWhenSourceSaved");
|
||||
ADD_int_OBJECT(NSUpdateManually,@"NSUpdateManually");
|
||||
ADD_int_OBJECT(NSUpdateNever,@"NSUpdateNever");
|
||||
ADD_int_OBJECT(NSChangeDone,@"NSChangeDone");
|
||||
ADD_int_OBJECT(NSChangeUndone,@"NSChangeUndone");
|
||||
ADD_int_OBJECT(NSChangeCleared,@"NSChangeCleared");
|
||||
ADD_int_OBJECT(NSSaveOperation,@"NSSaveOperation");
|
||||
ADD_int_OBJECT(NSSaveAsOperation,@"NSSaveAsOperation");
|
||||
ADD_int_OBJECT(NSSaveToOperation,@"NSSaveToOperation");
|
||||
ADD_int_OBJECT(NSDragOperationNone,@"NSDragOperationNone");
|
||||
ADD_int_OBJECT(NSDragOperationCopy,@"NSDragOperationCopy");
|
||||
ADD_int_OBJECT(NSDragOperationLink,@"NSDragOperationLink");
|
||||
ADD_int_OBJECT(NSDragOperationGeneric,@"NSDragOperationGeneric");
|
||||
ADD_int_OBJECT(NSDragOperationPrivate,@"NSDragOperationPrivate");
|
||||
ADD_int_OBJECT(NSDragOperationAll,@"NSDragOperationAll");
|
||||
ADD_int_OBJECT(GSFileWrapperDirectoryType,@"GSFileWrapperDirectoryType");
|
||||
ADD_int_OBJECT(GSFileWrapperRegularFileType,@"GSFileWrapperRegularFileType");
|
||||
ADD_int_OBJECT(GSFileWrapperSymbolicLinkType,@"GSFileWrapperSymbolicLinkType");
|
||||
ADD_int_OBJECT(NSControlGlyph,@"NSControlGlyph");
|
||||
ADD_int_OBJECT(NSNullGlyph,@"NSNullGlyph");
|
||||
ADD_int_OBJECT(NSGlyphBelow,@"NSGlyphBelow");
|
||||
ADD_int_OBJECT(NSGlyphAbove,@"NSGlyphAbove");
|
||||
ADD_int_OBJECT(NSOneByteGlyphPacking,@"NSOneByteGlyphPacking");
|
||||
ADD_int_OBJECT(NSJapaneseEUCGlyphPacking,@"NSJapaneseEUCGlyphPacking");
|
||||
ADD_int_OBJECT(NSAsciiWithDoubleByteEUCGlyphPacking,@"NSAsciiWithDoubleByteEUCGlyphPacking");
|
||||
ADD_int_OBJECT(NSTwoByteGlyphPacking,@"NSTwoByteGlyphPacking");
|
||||
ADD_int_OBJECT(NSFourByteGlyphPacking,@"NSFourByteGlyphPacking");
|
||||
ADD_int_OBJECT(NSItalicFontMask,@"NSItalicFontMask");
|
||||
ADD_int_OBJECT(NSUnitalicFontMask,@"NSUnitalicFontMask");
|
||||
ADD_int_OBJECT(NSBoldFontMask,@"NSBoldFontMask");
|
||||
ADD_int_OBJECT(NSUnboldFontMask,@"NSUnboldFontMask");
|
||||
ADD_int_OBJECT(NSNarrowFontMask,@"NSNarrowFontMask");
|
||||
ADD_int_OBJECT(NSExpandedFontMask,@"NSExpandedFontMask");
|
||||
ADD_int_OBJECT(NSCondensedFontMask,@"NSCondensedFontMask");
|
||||
ADD_int_OBJECT(NSSmallCapsFontMask,@"NSSmallCapsFontMask");
|
||||
ADD_int_OBJECT(NSPosterFontMask,@"NSPosterFontMask");
|
||||
ADD_int_OBJECT(NSCompressedFontMask,@"NSCompressedFontMask");
|
||||
ADD_int_OBJECT(NSNonStandardCharacterSetFontMask,@"NSNonStandardCharacterSetFontMask");
|
||||
ADD_int_OBJECT(NSFixedPitchFontMask,@"NSFixedPitchFontMask");
|
||||
ADD_int_OBJECT(NSNoFontChangeAction,@"NSNoFontChangeAction");
|
||||
ADD_int_OBJECT(NSViaPanelFontAction,@"NSViaPanelFontAction");
|
||||
ADD_int_OBJECT(NSAddTraitFontAction,@"NSAddTraitFontAction");
|
||||
ADD_int_OBJECT(NSRemoveTraitFontAction,@"NSRemoveTraitFontAction");
|
||||
ADD_int_OBJECT(NSSizeUpFontAction,@"NSSizeUpFontAction");
|
||||
ADD_int_OBJECT(NSSizeDownFontAction,@"NSSizeDownFontAction");
|
||||
ADD_int_OBJECT(NSHeavierFontAction,@"NSHeavierFontAction");
|
||||
ADD_int_OBJECT(NSLighterFontAction,@"NSLighterFontAction");
|
||||
ADD_int_OBJECT(NSFPPreviewButton,@"NSFPPreviewButton");
|
||||
ADD_int_OBJECT(NSFPRevertButton,@"NSFPRevertButton");
|
||||
ADD_int_OBJECT(NSFPSetButton,@"NSFPSetButton");
|
||||
ADD_int_OBJECT(NSFPPreviewField,@"NSFPPreviewField");
|
||||
ADD_int_OBJECT(NSFPSizeField,@"NSFPSizeField");
|
||||
ADD_int_OBJECT(NSFPSizeTitle,@"NSFPSizeTitle");
|
||||
ADD_int_OBJECT(NSFPCurrentField,@"NSFPCurrentField");
|
||||
ADD_int_OBJECT(NSFPFamilyBrowser,@"NSFPFamilyBrowser");
|
||||
ADD_int_OBJECT(NSFPFaceBrowser,@"NSFPFaceBrowser");
|
||||
ADD_int_OBJECT(NSFPSizeBrowser,@"NSFPSizeBrowser");
|
||||
ADD_int_OBJECT(NSBackingStoreRetained,@"NSBackingStoreRetained");
|
||||
ADD_int_OBJECT(NSBackingStoreNonretained,@"NSBackingStoreNonretained");
|
||||
ADD_int_OBJECT(NSBackingStoreBuffered,@"NSBackingStoreBuffered");
|
||||
ADD_int_OBJECT(NSCompositeClear,@"NSCompositeClear");
|
||||
ADD_int_OBJECT(NSCompositeCopy,@"NSCompositeCopy");
|
||||
ADD_int_OBJECT(NSCompositeSourceOver,@"NSCompositeSourceOver");
|
||||
ADD_int_OBJECT(NSCompositeSourceIn,@"NSCompositeSourceIn");
|
||||
ADD_int_OBJECT(NSCompositeSourceOut,@"NSCompositeSourceOut");
|
||||
ADD_int_OBJECT(NSCompositeSourceAtop,@"NSCompositeSourceAtop");
|
||||
ADD_int_OBJECT(NSCompositeDestinationOver,@"NSCompositeDestinationOver");
|
||||
ADD_int_OBJECT(NSCompositeDestinationIn,@"NSCompositeDestinationIn");
|
||||
ADD_int_OBJECT(NSCompositeDestinationOut,@"NSCompositeDestinationOut");
|
||||
ADD_int_OBJECT(NSCompositeDestinationAtop,@"NSCompositeDestinationAtop");
|
||||
ADD_int_OBJECT(NSCompositeXOR,@"NSCompositeXOR");
|
||||
ADD_int_OBJECT(NSCompositePlusDarker,@"NSCompositePlusDarker");
|
||||
ADD_int_OBJECT(NSCompositeHighlight,@"NSCompositeHighlight");
|
||||
ADD_int_OBJECT(NSCompositePlusLighter,@"NSCompositePlusLighter");
|
||||
ADD_int_OBJECT(NSWindowAbove,@"NSWindowAbove");
|
||||
ADD_int_OBJECT(NSWindowBelow,@"NSWindowBelow");
|
||||
ADD_int_OBJECT(NSWindowOut,@"NSWindowOut");
|
||||
ADD_int_OBJECT(GSTitleBarKey,@"GSTitleBarKey");
|
||||
ADD_int_OBJECT(GSTitleBarNormal,@"GSTitleBarNormal");
|
||||
ADD_int_OBJECT(GSTitleBarMain,@"GSTitleBarMain");
|
||||
ADD_int_OBJECT(NSScaleProportionally,@"NSScaleProportionally");
|
||||
ADD_int_OBJECT(NSScaleToFit,@"NSScaleToFit");
|
||||
ADD_int_OBJECT(NSScaleNone,@"NSScaleNone");
|
||||
ADD_int_OBJECT(NSImageAlignCenter,@"NSImageAlignCenter");
|
||||
ADD_int_OBJECT(NSImageAlignTop,@"NSImageAlignTop");
|
||||
ADD_int_OBJECT(NSImageAlignTopLeft,@"NSImageAlignTopLeft");
|
||||
ADD_int_OBJECT(NSImageAlignTopRight,@"NSImageAlignTopRight");
|
||||
ADD_int_OBJECT(NSImageAlignLeft,@"NSImageAlignLeft");
|
||||
ADD_int_OBJECT(NSImageAlignBottom,@"NSImageAlignBottom");
|
||||
ADD_int_OBJECT(NSImageAlignBottomLeft,@"NSImageAlignBottomLeft");
|
||||
ADD_int_OBJECT(NSImageAlignBottomRight,@"NSImageAlignBottomRight");
|
||||
ADD_int_OBJECT(NSImageAlignRight,@"NSImageAlignRight");
|
||||
ADD_int_OBJECT(NSImageFrameNone,@"NSImageFrameNone");
|
||||
ADD_int_OBJECT(NSImageFramePhoto,@"NSImageFramePhoto");
|
||||
ADD_int_OBJECT(NSImageFrameGrayBezel,@"NSImageFrameGrayBezel");
|
||||
ADD_int_OBJECT(NSImageFrameGroove,@"NSImageFrameGroove");
|
||||
ADD_int_OBJECT(NSImageFrameButton,@"NSImageFrameButton");
|
||||
ADD_int_OBJECT(NSUtilityWindowMask,@"NSUtilityWindowMask");
|
||||
ADD_int_OBJECT(NSDocModalWindowMask,@"NSDocModalWindowMask");
|
||||
ADD_int_OBJECT(NSOKButton,@"NSOKButton");
|
||||
ADD_int_OBJECT(NSCancelButton,@"NSCancelButton");
|
||||
ADD_int_OBJECT(NSAlertDefaultReturn,@"NSAlertDefaultReturn");
|
||||
ADD_int_OBJECT(NSAlertAlternateReturn,@"NSAlertAlternateReturn");
|
||||
ADD_int_OBJECT(NSAlertOtherReturn,@"NSAlertOtherReturn");
|
||||
ADD_int_OBJECT(NSAlertErrorReturn,@"NSAlertErrorReturn");
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
/* -- End of file -- */
|
135
Modules/AppKit/AppKitEvents.list
Normal file
135
Modules/AppKit/AppKitEvents.list
Normal file
|
@ -0,0 +1,135 @@
|
|||
# AppKit Events and Keys
|
||||
#
|
||||
|
||||
int NSLeftMouseDown
|
||||
int NSLeftMouseUp
|
||||
int NSOtherMouseDown
|
||||
int NSOtherMouseUp
|
||||
int NSRightMouseDown
|
||||
int NSRightMouseUp
|
||||
int NSMouseMoved
|
||||
int NSLeftMouseDragged
|
||||
int NSOtherMouseDragged
|
||||
int NSRightMouseDragged
|
||||
int NSMouseEntered
|
||||
int NSMouseExited
|
||||
int NSKeyDown
|
||||
int NSKeyUp
|
||||
int NSFlagsChanged
|
||||
int NSAppKitDefined
|
||||
int NSSystemDefined
|
||||
int NSApplicationDefined
|
||||
int NSPeriodic
|
||||
int NSCursorUpdate
|
||||
int NSScrollWheel
|
||||
|
||||
|
||||
int NSBackspaceKey
|
||||
int NSCarriageReturnKey
|
||||
int NSDeleteKey
|
||||
int NSBacktabKey
|
||||
|
||||
int NSUpArrowFunctionKey
|
||||
int NSDownArrowFunctionKey
|
||||
int NSLeftArrowFunctionKey
|
||||
int NSRightArrowFunctionKey
|
||||
int NSF1FunctionKey
|
||||
int NSF2FunctionKey
|
||||
int NSF3FunctionKey
|
||||
int NSF4FunctionKey
|
||||
int NSF5FunctionKey
|
||||
int NSF6FunctionKey
|
||||
int NSF7FunctionKey
|
||||
int NSF8FunctionKey
|
||||
int NSF9FunctionKey
|
||||
int NSF10FunctionKey
|
||||
int NSF11FunctionKey
|
||||
int NSF12FunctionKey
|
||||
int NSF13FunctionKey
|
||||
int NSF14FunctionKey
|
||||
int NSF15FunctionKey
|
||||
int NSF16FunctionKey
|
||||
int NSF17FunctionKey
|
||||
int NSF18FunctionKey
|
||||
int NSF19FunctionKey
|
||||
int NSF20FunctionKey
|
||||
int NSF21FunctionKey
|
||||
int NSF22FunctionKey
|
||||
int NSF23FunctionKey
|
||||
int NSF24FunctionKey
|
||||
int NSF25FunctionKey
|
||||
int NSF26FunctionKey
|
||||
int NSF27FunctionKey
|
||||
int NSF28FunctionKey
|
||||
int NSF29FunctionKey
|
||||
int NSF30FunctionKey
|
||||
int NSF31FunctionKey
|
||||
int NSF32FunctionKey
|
||||
int NSF33FunctionKey
|
||||
int NSF34FunctionKey
|
||||
int NSF35FunctionKey
|
||||
int NSInsertFunctionKey
|
||||
int NSDeleteFunctionKey
|
||||
int NSHomeFunctionKey
|
||||
int NSBeginFunctionKey
|
||||
int NSEndFunctionKey
|
||||
int NSPageUpFunctionKey
|
||||
int NSPageDownFunctionKey
|
||||
int NSPrintScreenFunctionKey
|
||||
int NSScrollLockFunctionKey
|
||||
int NSPauseFunctionKey
|
||||
int NSSysReqFunctionKey
|
||||
int NSBreakFunctionKey
|
||||
int NSResetFunctionKey
|
||||
int NSStopFunctionKey
|
||||
int NSMenuFunctionKey
|
||||
int NSUserFunctionKey
|
||||
int NSSystemFunctionKey
|
||||
int NSPrintFunctionKey
|
||||
int NSClearLineFunctionKey
|
||||
int NSClearDisplayFunctionKey
|
||||
int NSInsertLineFunctionKey
|
||||
int NSDeleteLineFunctionKey
|
||||
int NSInsertCharFunctionKey
|
||||
int NSDeleteCharFunctionKey
|
||||
int NSPrevFunctionKey
|
||||
int NSNextFunctionKey
|
||||
int NSSelectFunctionKey
|
||||
int NSExecuteFunctionKey
|
||||
int NSUndoFunctionKey
|
||||
int NSRedoFunctionKey
|
||||
int NSFindFunctionKey
|
||||
int NSHelpFunctionKey
|
||||
int NSModeSwitchFunctionKey
|
||||
|
||||
int NSLeftMouseDownMask
|
||||
int NSLeftMouseUpMask
|
||||
int NSOtherMouseDownMask
|
||||
int NSOtherMouseUpMask
|
||||
int NSRightMouseDownMask
|
||||
int NSRightMouseUpMask
|
||||
int NSMouseMovedMask
|
||||
int NSLeftMouseDraggedMask
|
||||
int NSOtherMouseDraggedMask
|
||||
int NSRightMouseDraggedMask
|
||||
int NSMouseEnteredMask
|
||||
int NSMouseExitedMask
|
||||
int NSFlagsChangedMask
|
||||
int NSAppKitDefinedMask
|
||||
int NSSystemDefinedMask
|
||||
int NSApplicationDefinedMask
|
||||
int NSPeriodicMask
|
||||
int NSCursorUpdateMask
|
||||
int NSScrollWheelMask
|
||||
int NSAnyEventMask
|
||||
|
||||
int NSAlphaShiftKeyMask
|
||||
int NSAlternateKeyMask
|
||||
int NSCommandKeyMask
|
||||
int NSControlKeyMask
|
||||
int NSFunctionKeyMask
|
||||
int NSHelpKeyMask
|
||||
int NSKeyDownMask
|
||||
int NSKeyUpMask
|
||||
int NSNumericPadKeyMask
|
||||
int NSShiftKeyMask
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue