00001
00002
00003
00004
00005
00006
00007
00008
00009
00014 #include <iostream>
00015 #include <string>
00016 #include "defs.hpp"
00017 #include "class.hpp"
00018 #include "method_info.hpp"
00019 #include "bytecode.hpp"
00020
00021 using namespace std;
00022
00023 int main( int argc, char **argv )
00024 {
00025 Class test;
00026 method_info *method = test.addMethod( "<init>" );
00027 ByteCode *code = method->code();
00028 code->emit_aload( 0 );
00029 code->emit_invokespecial( "java/lang/Object", "<init>", "()V" );
00030 code->emit_return();
00031 method->finish();
00032
00033 method = test.addMethod( "main" );
00034 method->setAccess( ACC_PUBLIC | ACC_STATIC );
00035 method->addParameter( "java/lang/String", true );
00036 code = method->code();
00037 code->emit_getstatic( "java/lang/System", "out", "Ljava/io/PrintStream;" );
00038 code->emit_sipush( 42 );
00039 code->emit_invokevirtual( "java/io/PrintStream", "println", "(I)V" );
00040 code->emit_return();
00041 method->finish();
00042
00043 test.write( "output.class" );
00044 return 0;
00045 }