Commit graph

1087 commits

Author SHA1 Message Date
joeduffy 71855c7c44 Split intrinsics
This change just refactors out the dynamic intrinsics functions, from the general
intrinsics file, in preparation for some new ones.
2017-05-13 19:22:52 -04:00
joeduffy ea7658f338 Guard against nil diffs 2017-05-08 14:52:17 -05:00
joeduffy d3c1d7057b Add some tests for stable property ordering 2017-05-06 16:22:06 -07:00
joeduffy 7d8aadeb1e Implement chronological stable object keys
We need a stable object key enumeration order and we might as well leverage
ECMAScript's definition for this.  As of ES6, key ordering is specified; see
https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys.

I haven't fully implemented the "numbers come first part" (we can do this as
soon as we have support for Object.keys()), but the chronological part works.
2017-05-06 16:09:49 -07:00
joeduffy 3e73a6b8ba Add an alloc.NewDynamic helper function 2017-05-06 15:39:39 -07:00
joeduffy fb3a6612f6 Fix a lambda lexical environment bug
This addresses a bug where we did not reconstruct the correct lexical
environment when restoring a lambda's captured context.  Namely, the local
variables scope "drifted" with respect to the evaluation scope slots.

This is an example program that triggered it:

    function mkeighty() {
        let eighty = 80;
        return () => eighty;
    }
    let group = new ec2.SecurityGroup(..., {
        ingress: [ ..., fromPort: mkeighty()(), ... ],
    });

I am going to work on turning this into a regression test with my next
checkin; there's a fair bit of test infrastructure "machinery" I need
to put in place, but the time has come to lay the foundation.
2017-05-04 16:38:46 -07:00
joeduffy 240cdb8f0f Implement lambdas in the runtime
This change completes implementing lambdas in the runtime, closing
out pulumi/coconut#62.  The change is mostly straightforward, with
most changes coming down to the fact that functions may now exist
that themselves aren't definitions (like class/module members).
The function stub machinery has also been updated to retain the
environment in which a lambda was created, effectively "capturing"
the lexically available variables.  Note that this is *not* dynamic
scoping, which will be a problem down the road when/if we want to
support Ruby.  My guess is we'll just have a completely different
DynamicallyScopedLambdaExpression opcode.
2017-05-04 14:03:51 -07:00
joeduffy 6822139406 Add a reference to x variable in test case 2017-05-04 11:04:28 -07:00
joeduffy 0de32db954 Add support for local functions
This change, part of pulumi/coconut#62, adds support for ECMAScript
local functions.  This leverages the recent support for lambdas.
The change also adds some new test cases for the various forms.

Here are some examples of supported forms:

    function outer() {
        // simple named inner function:
        function inner1() { .. };
        // anonymous inner function (just a lambda):
        let inner2 = function() { ... };
        // named and bound inner function:
        let inner3 = function inner4() { ... };
    }

These merely compile into lambdas that have been bound to local
variables with the appropriate names.
2017-05-04 10:57:26 -07:00
joeduffy fde88b7cf4 Permit Statements in SequenceExpressions
The previous shape of SequenceExpression only permitted expressions
in the sequence.  This is pretty common in most ILs, however, it usually
leads to complicated manual spilling in the event that a statement is needed.
This is often necessary when, for example, a compiler is deeply nested in some
expression production, and then realizes the code expansion requires a
statement (e.g., maybe a new local variable must be declared, etc).

Instead of requiring complicated code-gen, this change permits SequenceExpression
to contain an arbitrary mixture of expression/statement prelude nodes, terminating
with a single, final Expression which yields the actual expression value.  The
runtime bears the burden of implementing this which, frankly, is pretty trivial.
2017-05-04 10:54:07 -07:00
joeduffy 748432299a Implement lambdas in CocoJS
This change recognizes and emits lambdas correctly in CocoJS (as part
of pulumi/coconut#62).  The existing CocoIL representation for lambdas
worked just fine for functions, lambdas, and local functions.  There
still isn't runtime support, but that comes next.
2017-05-04 10:01:05 -07:00
joeduffy 1e67162331 Fix a couple silly mistakes 2017-05-04 09:53:52 -07:00
joeduffy 70e75063c2 Remove superfluous output from install.sh 2017-05-01 17:43:50 -07:00
joeduffy 7f634b4cf2 Remove pulumi/coconut#141 workaround 2017-05-01 17:13:30 -07:00
joeduffy 4e5140251b Implement support for computed property initializers
I've tripped over pulumi/coconut#141 a few times now, particularly with
the sort of dynamic payloads required when creating lambdas and API gateways.
This change implements support for computed property initializers.
2017-05-01 17:11:57 -07:00
joeduffy bcd44fc06f Update cross-cloud library to support the latest changes 2017-05-01 10:21:52 -07:00
joeduffy 08626715fd Revert change to managed policy ARN casing 2017-05-01 10:17:18 -07:00
joeduffy 5c156a43cf Permit missing symbols in more places 2017-05-01 10:11:20 -07:00
joeduffy 815aa26282 Improve a contract.fail error message 2017-05-01 09:46:59 -07:00
joeduffy 553462bbfd Lower level for transformSourceFile logging
This changes the CocoJS log-level for logging about transforming a file
so that it shows up in --verbose logging.
2017-05-01 09:45:09 -07:00
joeduffy c1696dc684 Regenerate Kubefission with latest CIDLC 2017-05-01 09:41:02 -07:00
joeduffy 6902d7e1b2 Update AWS Lambdas to take archives, not assets 2017-05-01 09:38:23 -07:00
joeduffy 335ea01275 Implement archives
Our initial implementation of assets was intentionally naive, because
they were limited to single-file assets.  However, it turns out that for
real scenarios (like lambdas), we want to support multi-file assets.

In this change, we introduce the concept of an Archive.  An archive is
what the term classically means: a collection of files, addressed as one.
For now, we support three kinds: tarfile archives (*.tar), gzip-compressed
tarfile archives (*.tgz, *.tar), and normal zipfile archives (*.zip).

There is a fair bit of library support for manipulating Archives as a
logical collection of Assets.  I've gone to great length to avoid making
copies, however, sometimes it is unavoidable (for example, when sizes
are required in order to emit offsets).  This is also complicated by the
fact that the AWS libraries often want seekable streams, if not actual
raw contiguous []byte slices.
2017-04-30 12:37:24 -07:00
joeduffy 06b6ce3e44 Add a GH CI/CD sample
This is the code we want to get working with pulumi/coconut#134.
My goal this week is to make that happen!
2017-04-30 09:05:02 -07:00
joeduffy 69df382da9 Update the CIDLC README with build, running, etc. instructions 2017-04-30 08:36:57 -07:00
joeduffy 35a86d9089 Move AWS instanceMaps module back to ec2 2017-04-29 16:01:13 -07:00
joeduffy 0e16aa5d93 Make resource names the first constructor parameter
This reverts back to the old style of having the resource name as its
first parameter in the generated package.  Stylistically, this reads a
little nicer, and also ensures we don't need to rewrite all our existing
samples/test cases, etc.
2017-04-29 15:58:34 -07:00
joeduffy fa24d436e3 Unpointerize some types
In a few places, an IDL type will be a pointer, but the resulting
RPC code would, ideally, be the naked type.  Namely, in both resource
and asset cases, they are required to be pointers in the IDL (because
they are by-pointer by nature), but the marshaled representations need
not be pointers.  This change depointerizes such types in the RPC
unless, of course, they are optional in which case pointers still make
sense.  This avoids some annoying dereferencing and is the kind of thing
we want to do sooner before seeing widespread use.
2017-04-29 15:38:56 -07:00
joeduffy fe93f5e76f Strongly type resource IDs in the IDL/RPC/Providers
This change simply uses the `resource.ID` type in all the places
where it belongs, rather than using `string`-typed resource IDs.
2017-04-29 13:27:39 -07:00
joeduffy d8627697df Unglide AWS provider
This triggers complicates with local development, due to the way
that Glide vendors dependencies.  After we move to distinct repos
for the various provider packages, we can go back to doing this.
2017-04-29 13:26:39 -07:00
joeduffy 2e49e87e38 Add an IDL generation script for Kube Fission 2017-04-29 13:23:26 -07:00
joeduffy 1a0066b938 Commit generated code for Kube Fission package 2017-04-28 16:37:10 -07:00
joeduffy 8bb31a8dd9 Migrate Kube Fission provider to new IDL model 2017-04-28 16:36:43 -07:00
joeduffy d1dccb1b0a Further simplify the AWS provider
Now that the IDL types encode named resources as a first class concept,
there is no need to do the dynamic overriding dance in the AWS provider.
I should have included this in my final "banking" of the IDL changes.
2017-04-28 16:18:19 -07:00
joeduffy 3d391f3a44 Add the AWS package's CIDLC generated code
This change includes all of the CIDLC generated code for the AWS
package.  Just as we vendor and version the generated gRPC code,
we will do so for these files also.  This allows building of the
full packages without needing to run any special tools, in addition
to letting us keep track of generated code deltas over time.
2017-04-28 15:40:40 -07:00
joeduffy 3a4866f7c1 Add manually managed AWS package files
This checkin contains all the non-generated package files.  This includes
the package metadata, utility functions like utils/instanceMaps, and the
module layouts (these being a candidate for auto-generation down the road).

In addition, the install script has been updated fo reflect the new layout.
2017-04-28 15:38:45 -07:00
joeduffy ec03441a15 Eliminate old TypeScript resource definitions
The old TypeScript resource definitions may now go away in favor of
the new IDL and associated generated code.  After this change, I will
check in the generated code, so that the repo is self-contained.
2017-04-28 15:36:22 -07:00
joeduffy aca61a2074 Add missing Lambda Permisssion IDL type 2017-04-28 15:29:13 -07:00
joeduffy 59573fc05f Finish projecting AWS IDL types
This converts the remaining AWS resource types over to the new IDL
model; this includes the apigateway, cloudwatch, sns, and sqs packages.
2017-04-28 15:22:44 -07:00
joeduffy b381d23393 Ensure all errors correlate back to the IDL source 2017-04-28 15:21:22 -07:00
joeduffy 6952fd55f0 Track named resources
This change adds some conditional output that depends on whether a
named resource was contained in a file or not.  This eliminates some
compiler errors in the generated code when using manually-named
resources.
2017-04-28 15:03:24 -07:00
joeduffy 7e057cd1b5 Permit maps in IDL 2017-04-28 15:03:09 -07:00
joeduffy e2e73cf035 Use good package names in place of "rpc"
This is just a minor stylistic change.  Instead of letting the AWS
package imports take the good names, prefer to use the generated IDL
names (since they contain the strongly typed data structures).
2017-04-28 13:04:10 -07:00
joeduffy 93255b7e8f Convert the AWS S3 provider to the new IDL model 2017-04-28 12:58:51 -07:00
joeduffy 77fc639286 Don't mangle RPC package names 2017-04-28 12:42:31 -07:00
joeduffy 1489a73b18 Convert the AWS Lambda module to CIDLC 2017-04-28 12:27:19 -07:00
joeduffy 5ae168d23c Emit interface{} as just interface{} 2017-04-28 12:09:17 -07:00
joeduffy 40ac0a1d2b Support assets in the IDL 2017-04-28 12:07:49 -07:00
joeduffy f5c6af505a Properly fetch pointer elements 2017-04-28 11:46:35 -07:00
joeduffy 42ce8744ce Update the code-gen warning text 2017-04-28 11:35:33 -07:00