On Fri, Jul 1, 2016 at 5:16 AM, Abhishek Singh <[email protected]> wrote: > Hi, > > As part of v8 embedding work recently, I've encountered one more use case: > > Sample app.js: > =========== > > var database_table = "beer_sample"; > var city = "BLR"; > > // "query" is a FunctionTemplate exposed via an ObjectTemplate > var queryResult = query("select * from $database_table where > $database_table.city= $city"); > > // Assuming "city" is top level json field in documents within that DB > table, sample doc could look like: > // {"beer_count": 1000, city: "BLR", "brewery_location": > "business_district"} > > =========== > > Within the C++ Handler FunctionTemplate of "query" call needs to poke at > what was the state of stack variables in JS and after replacing it, it would > require to fire query. Just to clarify, query that Handler would require to > fire: > > "select * from beer-sample where beer-sample.city= BLR" > > Please suggest if there is a way to do this currently using v8, else I > suppose I would require to convert JS source to AST and after replacing > variables appropriately I would need to convert AST to valid JS source.
You could inspect the stack frame using the debug API (consult src/debug/debug.js and src/debug/mirrors.js) but it's arguably a bit daft and certainly inefficient. A more idiomatic and portable JS solution would be tagged template literals[0]. [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
