Giter VIP home page Giter VIP logo

ent's People

Contributors

anthonycanino1 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

w11wsbr1cc1l1

ent's Issues

Typesystem special cases (Allowing ModeSubstType and Types to check)

Currently we allow a ModeSubstType and a regular Type to be able to match on type system methods (typeEquals, isSubtype, descendsFrom, isImplicitCastValid, isCastValid). What this means is that if the type system attempts to check a type against one that has been substituted instead of erroring we forward this call to the ModeSubstType's base type.

This allows much more of the type system to type check without horribly affecting soundness. The alternative is to make sure every possible type is always mode substituted, which is tricky to do with the compiler internals, not external code (as that can be caught and fixed in the class loader).

Mcase implementation and resolution

mcases work correct when the assumption is made that they will be resolved on use, and mcase types see through to the base type. Things like the following work, but are not sound...

class A {
  mcase<int> f1 = mcase<int> {
    low: 0;
    mid: 1;
    high: 2;
  };

  public int getF1() {
    return this.f1;
  }
}

However, attempting to return an mcase does not work...

public mcase<int> getF1() {
  return this.f1;  // Will error
}

This is more of a design issue on how mcases should be implemented. Will revisit.

Restrict ModeValues to proper contexts

ModeValues use should be restricted to attributor and snapshot bounds only. Currently they can used anywhere (but it will always cause a compile error).

See
ModeValue_c.java

Add full mode type variable inference

Right now a type's mode type will be set to the wildcard mode type if the mode type is elided. This helps us prototype, but eventually an elided mode type should create a mode type variable that is then subject to inference.

Mode Subst subtyping

Just like generics can be extended, the same needs to be done with generic mode types. This needs to get added in, and is probably closely related with the java.lang.Object issue.

ModeSubst/ModeSubstEngine caching

polyglot encapsulates type substitutions on generic classes (SubstClassType) with a Subst object (similar to our ModeSubst object). One major difference is that Subst objects are unique (all equivalent substitutions use the same object) which is cached for performance and equality checks. Our ModeSubst should be converted to something similar.

See
panda.types.ModeSubst.java
panda.types.ModeSubstEngine.java

JL5/JL Codegen

We currently attempt to output JL5 code (we use JL5OutputExtensionInfo) by using an extension rewrite pass. There are two issues with this.

  • If extRewrite is defined for a polyglot node, it rewrites to JL, not JL5.
  • If extRewrite is NOT defined then Node.java will call copy(NodeFactory) which itself not always defined.

The quick solution is to extend the node (with a PandaExt) and manually copy it during the rewriting. A better solution is to figure out exactly how polyglot removes java 5 constructs and perhaps tap into that to be more consistent.

Panda does not serialize mode types properly

Serialization/deserialization needs to be handled inside Panda if we ever want to seriously produce energy libraries.

The issue is that ModeTypes are not ClassTypes, thus deserialization does not link created mode types properly (one set of .class files has a different 'WildcardModeType' than another). In other words, we loose reference equality.

The same issue will happen with declared modes, but for now there is a hack in place (done in the deserialization of ModeSubstType) to fix wildcards and dynamics.

Array implementation

Arrays do not currently support mode types. An array will be given a ModeSubstArrayType in the type system, but the language does not support anything further.

This is a nontrivial issue. Array dims have to be handled, which means that mode type have to be substituted across the dims (i.e. what does a String@mode[] mean?). Will revisit.

Mcase resolution with a wildcard mode type crashes

If we allow wildcard mode types to be carried through to the runtime (this is done until inference is implemented) then we need a way to properly allow an mcase resolution for an object with a wildcard mode type.

Either default it to high, or translate wildcard mode types before passing to the runtime (this could lead to issues as well).

Field Access / Call Typechecking

We allow Field Access and Call's to also work on types that have not be mode substituted (same as issue #5). This is for code that is loaded that has not been given a mode substituted type (but all compiled code will not hit this).

We will revisit this issue.

TypeVariable Mode Subst

TypeVariables are an interesting problem for mode substitution. Right now they are ignored, but they need to be handled. The problem is that type variables really gain their type when they are instantiated, but that instantiation needs to be checked against the constraints.

Our constraint checking is going to have to add and save some information to the type system. Simply erasing generics is not going to work.

Annonymous classes are not given a ModeSubstType.

Issue can be seen when compiling sunflow (SunflowGUI.java:484) on type <anonymous subtype of java.awt.event.ActionListener@mode<*>>.

Break at PandaNewExt.java:152. Temporarily passing up to parent language for now.

Subst Warnings

Currently (related to previous issue as well) not all classes are substituted (java.lang.Object) being one of them.

A lot of this can be seen when working with generics (java generics) and the warning are left in the compiler to remind me to return to them.

Method mode type parameter subs looks like it causes many of these issues to pop up, reminder to revisit.

Snapshot Optimization

snapshot is currently implemented and working in the language. There are some simple optimizations that can be should be added however.

  • Semantic checking for what will statically always fail. This check will need to take in to account the range of the attributor and the range of the snapshot.
  • Remove range check if snapshot will never fail. This requires some new functionality to be added to the runtime (unsafe PANDA_Snapshot.snapshot etc).

See
panda.ast.SnapshotExpr.java
panda.runtime.PANDA_Snapshot.java

java.lang.Object Mode Subst

Some of the builtin classes are not substituted which becomes a problem after all other classes have been. Polyglot creates singleton objects for these classes which can be intercepted and substituted, but they may need to be substituted with a type variable. The actual problem arises when a class subclasses these, which may need a specific work around versus some kind of major substitution, since that is not really the right answer.

i.e.

String extends Object is originally ParsedClassType extends ParsedClassType, but String will be substituted at inst time, resulting in something like ModeSubstClassType extends ParsedClassType. A ModeSubstClassType should handle this, since if the parent class was not declared with a mode, it should be the same as the mode assigned to the child.

JL7Switch and JL7Case

We need to translate these properly; I write directly to JL5 from Panda which will recheck a switch over a string and fail in the JL5 pass.

See issue #14. It's the same problem.

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.