Giter Site home page Giter Site logo

hhvm / hack-codegen Goto Github PK

View Code? Open in Web Editor NEW
337.0 63.0 93.0 2.05 MB

Library to programatically generate Hack code and write it to signed files

Home Page: https://hhvm.github.io/hack-codegen/

License: MIT License

Hack 100.00%
hacklang codegen

hack-codegen's People

Contributors

alejandromarcu avatar alexeyt avatar aloiret avatar atry avatar azjezz avatar chipcius avatar dependabot[bot] avatar dienesl avatar elgenie avatar fredemmott avatar gauravkdeo avatar gmarcotte avatar jjergus avatar kmeht avatar lexidor avatar mwildehahn avatar neitsch avatar siebelstim avatar simonwelsh avatar usox avatar wilfred avatar wlin53 avatar yurybandarchuk16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hack-codegen's Issues

Fix fixmes for variadics

/* HH_FIXME[4033] variadic params with type constraints are not supported */

Given that 3.12 support has been dropoped, these can all be cleaned up

Remaining documentation

  • CodegenClassBase
  • CodegenEnum
  • CodegenWithInterfaces
  • CodegenInterface
  • CodegenTrait
  • CodegenClass
  • CodegenType
  • CodegenShape

Migrate to dict/keyset/vec

Not sure if this'll be in v3.0 or not - this depends on the state of their support in HHVM at the time.

Remove LegacyHelpers

These don't need to stay around for 2.0 - they're only still there because I've not had time to update the unit tests yet

Document major changes

Highlights:

  • no global config object
  • container definitions are nestable
  • container order is preserved
  • removed behavior where many methods would sometimes interpret the first arg as a plain string, sometimes a format string. The old function name always takes a plain string, 'f' suffix takes a format string, with typechecker validation - eg addReturn('plainstring') and addReturnf('formatstring', ...')
  • use PHPUnit instead of custom framework

Full list: v1.1.4...master

addAssignment doesn't support assigning to static properties

HackBuilder->assertIsVariable checks that the passed in variable starts with a $, which means you can't use it to assign to static:: or self::

Replication:

$cgf->codegenHackBuilder()
  ->addAssignment('static::$foo', 'Bar', HackBuilderValues::export())
  ->getCode();

Expected result:

static::$foo = 'Bar';

Actual result:

Fatal error: Uncaught exception 'HH\InvariantException' with message 'Expecting a variable name, but "static::$foo" is not valid.'

Add utility scripts to verify signed sources

Probably two:

  • hack-codegen-verify-signature.php $file1 [$file2 [ $file3 ...: error if files don't have a valid signature
  • hack-codegen-verify-if-signed.php $file1 [$file2 [ $file3...: allow unsigned files, but not files with invalid signatures

Put these in vendor/bin/ when installed via composer, and suggest using them for commit hooks in the documentation.

Support nested HackBuilderValues definitions

For example, I have an ImmMap<string, ImmMap<string, classname<T>>; I'd like to codegen the same. addImmMap() on that gives me ImmMap<string, ImmMap<string, string>>.

I can work around this by codegen'ing separate locals for each variable as immaps with literal values after mapping ($value ==> "\\".$value.'::class'), then creating the outer ImmMap from these locals also with literal values. It would be good not to have this intermediate step.

Document usage scenarios

Outside of Facebook, by default:

  • the typechecker is automatically ran on page requests
  • a typechecker error is fatal

This means that this code can not be ran if there are any references to undefined classes in the tree, including classes that are generated by codegen, so, it seems that:

  • codegen files should be committed to the repo
  • codegen files need to be created before any references to them are added

By comparison, https://github.com/hhvm/user-documentation approach (which has a much less clean implementation than this) is:

  • manually written .hhi files are committed to the repo, and do not use hack-specific features
  • PHP code is generated as a build step

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.