Code Monkey home page Code Monkey logo

jspawn's People

Contributors

mzarnowski avatar

Watchers

 avatar

jspawn's Issues

Support constructors

Goals:
Spawned class can be instantiated using default constructor:

Class<?> spawned = ???;
Object instance = spawned.getDeclaredConstructor().newInstance();

Spawn a class with a field

Finished when:

  1. One can access a field of spawned class using reflection, e.g. spawnedClass.getDeclaredField("field").
  2. This field's getType method returns 'correct' type

Introduce ClassFile

Currently, class file is build in abstract steps defined in so called "compiler" package. But, since the process is very straightforward, we can simplify it a lot by introducing separate factories for many of these steps.

Gain:

  1. create class file explicitly and in a simpler manner
  2. define logic of creating objects (ClassFile, its pools) more closely to the actual object definitions

Spawn a class with an int returning method

Goals:

  1. A method returning an int can be obtained from a spawned class using reflection:
Class<?> spawned = ???
Method method = spawned.getDeclaredMethod("foo", int.class);
  1. This method, when invoked, will return - no surprises - an int value

Non-Goals:

  1. Allowing any other than int return type
  2. Introducing any non-push and non-return stack-instruction

Spawn a simple class

When:

  1. request was made to spawn a class of name pkg.Bar, extending Foo and implementing IFace.

Then

  1. We obtain an instance of Class named 'Bar' within package 'pkg'. It is assignable to both Foo and IFace

Spawn a class with a simple method

Goals:
A method can be obtained from a spawned class using reflection

Class<?> spawned = ???
spawned.getDeclaredMethod("foo");

Non-Goals:

  1. Having a method return anything
  2. Supporting methods with non-empty body

Support branching instructions

Goals:
Branching instruction consist of:
a) condition
b) target

supported conditions are:

ALWAYS, 
IF_EQUAL, IF_NOT_EQUAL, 
IF_SMALLER, IF_NOT_SMALLER,
IF_GREATER, IF_NOT_GREATER, 

IF_ZERO, IF_NOT_ZERO, 
IF_SMALLER_THAN_ZERO, IF_NOT_SMALLER_THAN_ZERO,
IF_GREATER_THAN_ZERO, IF_NOT_GREATER_THAN_ZERO, 

target should be represented by a new Label type. Alongside Label, a meta-instruction DefineLabel should be introduced. It would be interpreted during JVM instruction generation as 'assign current byte offset with given label'

Support stack reduction operations

Goals:
Reduction operations are ones, which take at least one operand from a stack and transform it in some predefined manner. A bit like a built in functions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.