hhvm / hack-codegen Goto Github PK
View Code? Open in Web Editor NEWLibrary to programatically generate Hack code and write it to signed files
Home Page: https://hhvm.github.io/hack-codegen/
License: MIT License
Library to programatically generate Hack code and write it to signed files
Home Page: https://hhvm.github.io/hack-codegen/
License: MIT License
/* 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
In particular, make sure they're exported as eg \HH\Vector or Vector, not HH\Vector - and look at HackBuilder::varExport
As these are required for sets, should be required for the renderers.
'Attributes' is how they are referred to by the HHVM docs, reflection, and the typechecker
Required to generate scripts
It's inconsistent. Small breaking change, but seems worthwhile.
forking + modifying is not a reasonable approach; not compatible with composer, and makes merging in upstream fixes harder.
Not sure if this'll be in v3.0 or not - this depends on the state of their support in HHVM at the time.
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
I have an ImmMap<string, classname<T>>
; it would be useful to be able to specify that the values should be exported by $x ==> "\\".$x.'::class'
directly, especially when nested (related: #12)
Highlights:
addReturn('plainstring')
and addReturnf('formatstring', ...')
Full list: v1.1.4...master
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.'
Only supports 'as' constraints
live any one
given nested value type definitions are now supported, this is unneeded and makes the API more verbose.
https://github.com/facebook/hack-codegen/blob/master/src/CodegenFile.php#L413
This makes sense if running in the context of the webserver, but is bad for normal cases. This definitely shouldn't be the default.
eg $class_builder->addAttribute('MockClass')->addAttribute('CodeGen', 'MyCodeGenScript');
Related: #19
Will probably rename setHasManualDeclarations() to setHasManualDeclarationSection()
Probably two:
hack-codegen-verify-signature.php $file1 [$file2 [ $file3 ...
: error if files don't have a valid signaturehack-codegen-verify-if-signed.php $file1 [$file2 [ $file3...
: allow unsigned files, but not files with invalid signaturesPut these in vendor/bin/
when installed via composer, and suggest using them for commit hooks in the documentation.
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.
Would be nice for generating scripts
Probably belongs on a per-file scope.
Outside of Facebook, by default:
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:
By comparison, https://github.com/hhvm/user-documentation approach (which has a much less clean implementation than this) is:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.