About the generation of Java applets.
Subject:This document explains how to build an applet from a Hase++ description and what are
the C++ construction to avoid in Hase++ project to facilitate the automatic generation of the Java applet.
Generation: How to generate an applet from a Hase++ project.
- log as an Hase user ( nsu -x hase ) and go the export/webhase/javahase directory:
nsu -x hase; cd \~ /export/webhase/javahase
- Creation of java files and html file : Project project\_name project\_directory. Where
project\_name is the name of edl and elf files, and project\_directory is the directory to find
the hase files.
e.g.: Project tomasulo \~ /Development/tomasulo/V1.3/
This phase may print some messages but should be completed without any errors.
- Compile java file : compileP project_name.
e.g.: compileP tomasulo
The java compile may print some messages (see error message explanation below).
- Execute project locally :
e.g.: exeP T tomasulo [ gif_directory ]
T is the first letter of the project in uppercase and tomasulo
is the name of the project name. You may optionally indicate the
path to find the gif files. The default is project_directory/bitmaps/.
- Generate Jar file for publying the applet:
e.g.: Jar tomasulo
This command will produce a jar file and will copy the html file into the current directory.
The Tomasulo.html file is the html file to be used by a browser for a remote access.
The lTomasulo.html file is the html file to be used locally with an applet viewer:
appletviewer lTomasulo.html
- You may have to replace global_fns.c function by java one to be more efficient. This can be
done declaring a global_fns.java file with one static public method replacing each C function. These
methods will be added into the main class (Tomasulo.java).
Note to facilitate the Java generation:
Generally speaking, avoid every thing that you know to be allowed in C++ and in Java.
Here are some examples:
- do not use integer as boolean :
e.g: use 'if (go != 0)' instead of 'if (go)'
or: 'while (done() == 0)' instead of 'while (!done())'
But you can and should use boolean as boolean, not as integers:
bool test = TRUE; if (test) ...
- do not declare variables others than (int, char, float, double) in the BODY part of a hase
description, use the CLASS_DECL instead.
You can now declare variables in functions or methods
- avoid the definition of method in the CLASS_DECL part:
e.g: avoid 'setStop(int x) { stop=x; }'
Prefer: 'void setStop(int x);' in the CLASS_DECL part and 'void clock::setStop(int x) { stop=x; }' in the
CLASS_DEF part.
- Always use the name convert for the function which convert instruction_set into string.
- Do not use java reserved words for identifiers (These words are case sensitive:):
class, public, private, protected, extends, null, final, static, synchronized, instanceof, interface,
abstract, implements.
e.g. use 'Null' instead of 'null'
- avoid the use of class names of java.lang.package (Integer, Math, Object, Double, Float, String, Char).
- Do not override operators (=, [], ., +, *, -, /, ... )
- specific C++ constructions : unsigned i1; int *p1= &i1;
How to make an applet works if the compilation generate some errors - Pragmas :
You can add some pragmas in the hase files. Pragmas are special command which are ignored by the
C++ compiler but parsed by my translator to altered the generated code.
Pragmas always starts by //>>>
- //>>>A any java compatible text
This will add the 'any java compatible text' in the generated code.
- //>>>I word sentence
This will insert 'sentence' in front of each 'word' in the following Hase++ line.
- //>>>D
This will consider the next line as a declaration (as if it had been put in the CLASS_DECL part.
- //>>>Sn comment
This will skip the n following lines and add the 'comment' instead.
Frederic Mallet
Last modified: Thu Dec 6 15:24:05 GMT 2001