Skip to content

Commit

Permalink
[java/runtime] begin resolving circular dependencies from RakudoObjec…
Browse files Browse the repository at this point in the history
…t to SharedTable
  • Loading branch information
Martin Berends committed Aug 25, 2010
1 parent dcf5ee5 commit e0399b0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 56 deletions.
107 changes: 93 additions & 14 deletions java/runtime/Makefile
Expand Up @@ -2,41 +2,87 @@

ALL_CLASSES = \
Rakudo/Metamodel/Hints.class \
Rakudo/Metamodel/REPRRegistry.class \
Rakudo/Serialization/SerializationContext.class \
Rakudo/Metamodel/RakudoObject.class \
Rakudo/Metamodel/Representation.class \
Rakudo/Metamodel/SharedTable.class \
Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class
Rakudo/Metamodel/REPRRegistry.class

# Rakudo/Metamodel/SharedTable.class
# Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class

all: $(ALL_CLASSES)

# compiles ok: (listed in dependency order)
Rakudo/Metamodel/Hints.class: Rakudo/Metamodel/Hints.java
javac Rakudo/Metamodel/Hints.java

#Rakudo/Metamodel/IBoxableRepresentation.class: Rakudo/Metamodel/IBoxableRepresentation.java
# javac Rakudo/Metamodel/IBoxableRepresentation.java

Rakudo/Metamodel/REPRRegistry.class: Rakudo/Metamodel/REPRRegistry.java
javac Rakudo/Metamodel/REPRRegistry.java

Rakudo/Serialization/SerializationContext.class: Rakudo/Serialization/SerializationContext.java
javac Rakudo/Serialization/SerializationContext.java

# There is a long circular dependency from RakudoObject to SharedTable.
# Handle it by compiling all the files involved in a single step.
# Thanks jnthn++ for the suggestion.
Rakudo/Metamodel/RakudoObject.class: Rakudo/Metamodel/RakudoObject.java \
Rakudo/Serialization/SerializationContext.class
javac Rakudo/Metamodel/RakudoObject.java
Rakudo/Serialization/SerializationContext.class \
Rakudo/Metamodel/Representation.java \
Rakudo/Metamodel/REPRRegistry.java \
Rakudo/Metamodel/SharedTable.java
javac \
Rakudo/Metamodel/RakudoObject.java \
Rakudo/Metamodel/Representation.java \
Rakudo/Metamodel/REPRRegistry.java \
Rakudo/Metamodel/SharedTable.java

Rakudo/Metamodel/Representations/RakudoCodeRef.class: Rakudo/Metamodel/Representations/RakudoCodeRef.java \
javac Rakudo/Runtime/ThreadContext.class
javac Rakudo/Metamodel/Representations/RakudoCodeRef.java

Rakudo/Metamodel/Representation.class: Rakudo/Metamodel/Representation.java \
Rakudo/Runtime/Context.class: Rakudo/Runtime/Context.java \
Rakudo/Metamodel/Representations/RakudoCodeRef.class \
Rakudo/Metamodel/RakudoObject.class
javac Rakudo/Metamodel/Representation.java
javac Rakudo/Runtime/Context.java

Rakudo/Runtime/ThreadContext.class: Rakudo/Runtime/ThreadContext.java \
Rakudo/Runtime/Context.class \
Rakudo/Metamodel/RakudoObject.class
javac Rakudo/Runtime/ThreadContext.java

# Dependency critical paths (1 and 2 are circular)
# (less significant dependencies omitted for simplicity)
#
# Hints
# |
# Serialization
# |
# +--------------> RakudoObject
# | |
# | SerializationContext
# | |
# | Representation
# | | | |
# | +--> RakudoCodeRef | REPRRegistry
# | | | |
# 1 2 Context |
# | | | |
# | +--- ThreadContext |
# | | |
# | IFindMethod |
# | | |
# +---------------- SharedTable
# |

Rakudo/Metamodel/IFindMethod.class: Rakudo/Metamodel/IFindMethod.java
Rakudo/Metamodel/RakudoObject.class \
Rakudo/Runtime/ThreadContext.class
javac Rakudo/Metamodel/IFindMethod.java

Rakudo/Metamodel/SharedTable.class: Rakudo/Metamodel/SharedTable.java \
Rakudo/Metamodel/IFindMethod.class \
Rakudo/Metamodel/Representation.class
javac Rakudo/Metamodel/SharedTable.java
# this file has the lambda expression code commented out, and needs
# this file has two lambda expression code commented out, and needs
# to be completed urgently
# end circular dependency

Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.class: Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.java \
javac Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.java
Expand All @@ -47,5 +93,38 @@ Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class: Rakudo/Metamodel/KnowHOW/KnowHOWREPR
Rakudo/Metamodel/Hints.class
javac Rakudo/Metamodel/KnowHOW/KnowHOWREPR.java

# System to report which files are older than their dotnet equivalents.
# Compare the reported files manually, and refresh the java file.
PORTED_SOURCE_FILES = \
Rakudo/Metamodel/Hints.java \
Rakudo/Serialization/SerializationContext.java \
Rakudo/Metamodel/RakudoObject.java \
Rakudo/Metamodel/Representation.java

# Java source code files "depend" on files in the dotnet/ directories,
# in the sense that they are manual translations. The following
# dependencies cause on C# that can only be satisfied by
# manual editing.
Rakudo/Metamodel/Hints.java: ../../dotnet/runtime/Metamodel/Representation.cs
@echo "warning: Rakudo/Metamodel/Hints.java is older than ../../dotnet/runtime/Metamodel/Representation.cs"

Rakudo/Serialization/SerializationContext.java: ../../dotnet/runtime/Serialization/SerializationContext.cs
@echo "warning: Rakudo/Serialization/SerializationContext.java is older than ../../dotnet/runtime/Serialization/SerializationContext.cs"

Rakudo/Metamodel/RakudoObject.java: ../../dotnet/runtime/Metamodel/RakudoObject.cs
@echo "warning: Rakudo/Metamodel/RakudoObject.java is older than ../../dotnet/runtime/Metamodel/RakudoObject.cs"

Rakudo/Metamodel/Representation.java: ../../dotnet/runtime/Metamodel/Representation.cs
@echo "warning: Rakudo/Metamodel/Representation.java is older than ../../dotnet/runtime/Metamodel/Representation.cs"

todoreport: $(PORTED_SOURCE_FILES)

clean:
perl -MExtUtils::Command -e rm_f $(ALL_CLASSES)

help:
@echo "In 6model/java/runtime you can make the following:"
@echo "all (default) compile everything"
@echo "clean remove compiled class files"
@echo "todoreport list files where dotnet version is newer than java"
@echo "help this summary"
23 changes: 0 additions & 23 deletions java/runtime/Rakudo/Metamodel/IBoxableRepresentation.java

This file was deleted.

2 changes: 2 additions & 0 deletions java/runtime/Rakudo/Metamodel/REPRRegistry.java
Expand Up @@ -2,6 +2,8 @@

import java.util.*; // ArrayList HashMap

import Rakudo.Metamodel.Representation;

/// <summary>
/// This is our central registry of representations.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions java/runtime/Rakudo/Metamodel/RakudoObject.java
@@ -1,18 +1,20 @@
package Rakudo.Metamodel;

//import Rakudo.Metamodel.SharedTable;
import Rakudo.Serialization.SerializationContext;

/// <summary>
/// The commonalities of every object.
/// </summary>
public interface RakudoObject
// public abstract class RakudoObject // the C# version
{
/// <summary>
/// Every object must have a way to refer to the shared table,
/// which contains the commonalities this object has.
/// </summary>
SharedTable getSTable();
void setSTable( SharedTable st );
// SharedTable getSTable();
// void setSTable( SharedTable st );
// SharedTable STable { get; set; } // the C# version

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions java/runtime/Rakudo/Metamodel/Representation.java
Expand Up @@ -14,29 +14,29 @@ public interface Representation
/// </summary>
/// <param name="HOW"></param>
/// <returns></returns>
RakudoObject type_object_for(RakudoObject HOW);
RakudoObject type_object_for(RakudoObject how);

/// <summary>
/// Creates a new instance based on the type object.
/// </summary>
/// <param name="WHAT"></param>
/// <returns></returns>
RakudoObject instance_of(RakudoObject WHAT);
RakudoObject instance_of(RakudoObject what);

/// <summary>
/// Checks if a given object is defined.
/// </summary>
/// <param name="Obj"></param>
/// <returns></returns>
boolean defined(RakudoObject Obj);
boolean defined(RakudoObject obj);

/// <summary>
/// Gets the current value for an attribute.
/// </summary>
/// <param name="ClassHandle"></param>
/// <param name="Name"></param>
/// <returns></returns>
RakudoObject get_attribute(RakudoObject Object, RakudoObject ClassHandle, String Name);
RakudoObject get_attribute(RakudoObject object, RakudoObject classHandle, String name);

/// <summary>
/// Gets the current value for an attribute, obtained using the
Expand All @@ -46,15 +46,15 @@ public interface Representation
/// <param name="Name"></param>
/// <param name="Hint"></param>
/// <returns></returns>
RakudoObject get_attribute_with_hint(RakudoObject Object, RakudoObject ClassHandle, String Name, int Hint);
RakudoObject get_attribute_with_hint(RakudoObject object, RakudoObject classHandle, String name, int hint);

/// <summary>
/// Binds the given value to the specified attribute.
/// </summary>
/// <param name="ClassHandle"></param>
/// <param name="Name"></param>
/// <param name="Value"></param>
void bind_attribute(RakudoObject Object, RakudoObject ClassHandle, String Name, RakudoObject Value);
void bind_attribute(RakudoObject object, RakudoObject classHandle, String name, RakudoObject value);

/// <summary>
/// Binds the given value to the specified attribute, using the
Expand All @@ -64,14 +64,14 @@ public interface Representation
/// <param name="Name"></param>
/// <param name="Hint"></param>
/// <param name="Value"></param>
void bind_attribute_with_hint(RakudoObject Object, RakudoObject ClassHandle, String Name, int Hint, RakudoObject Value);
void bind_attribute_with_hint(RakudoObject object, RakudoObject classHandle, String name, int hint, RakudoObject Value);

/// <summary>
/// Gets the hint for the given attribute ID.
/// </summary>
/// <param name="ClassHandle"></param>
/// <param name="Name"></param>
/// <returns></returns>
int hint_for(RakudoObject ClassHandle, String Name);
int hint_for(RakudoObject classHandle, String name);
}

20 changes: 11 additions & 9 deletions java/runtime/Rakudo/Metamodel/SharedTable.java
@@ -1,7 +1,7 @@
package Rakudo.Metamodel;

//import Rakudo.Metamodel.RakudoObject;
//import Rakudo.Metamodel.Representation;
import Rakudo.Metamodel.RakudoObject;
import Rakudo.Metamodel.Representation;
import Rakudo.Serialization.SerializationContext;

/// <summary>
Expand All @@ -15,12 +15,14 @@ public class SharedTable
/// <summary>
/// This finds a method with the given name or using a hint.
/// </summary>
public Object FindMethod =
new Object() {
public Object method() {
return new Object();
}
}; // TODO: find out how this is used, and complete it
// public Object FindMethod =
// new IFindMethod() {
// public Object FindMethod() {
// return new Object();
// }
// };


// public Func<ThreadContext, RakudoObject, string, int, RakudoObject> FindMethod =
// (TC, Obj, Name, Hint) =>
// {
Expand Down Expand Up @@ -92,7 +94,7 @@ public Object method() {
/// </summary>
public long TypeCacheID () {
long id;
synchronized(this) {
synchronized(this) { // is locking the entire SharedTable too coarse?
TypeCacheIDSource += 4;
id = TypeCacheIDSource;
}
Expand Down

0 comments on commit e0399b0

Please sign in to comment.