Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixup a problem with cacheing of library files. allow disabling of ca…

…che feature
  • Loading branch information...
commit 80d12a7c45e3feb93a7788c6f3a073afabe91b2c 1 parent dccea8f
@maxtaco authored
Showing with 29 additions and 18 deletions.
  1. +1 −1  Makefile
  2. +4 −1 lib/parser.js
  3. +24 −15 lib/tamejs.js
  4. +0 −1  meetup.sh
View
2  Makefile
@@ -10,7 +10,7 @@ test/harness.js: test/harness.tjs lib/parser.js
build: lib/parser.js test/harness.js
clean:
- rm -f lib/parser.js test/harness.js test/cases/*.out.js
+ rm -f lib/parser.js test/harness.js test/cases/*.out.js test/cases/lib/.*.cache
test: test/harness.js
./test/harness.js
View
5 lib/parser.js
@@ -1,5 +1,6 @@
/* Jison generated parser */
var parser = (function(){
+
var parser = {trace: function trace() { },
yy: {},
symbols_: {"error":2,"String":3,"String1":4,"String2":5,"QUOTE1":6,"StringAtoms":7,"QUOTE2":8,"StringAtom":9,"STRING_ATOM":10,"InnerExprAtom":11,"OuterExprAtom":12,"LABEL":13,"BraceExpr":14,"FunctionDeclaration":15,"InnerExprAtomList":16,"InnerExpr":17,"ParenExpr":18,"LPAREN":19,"RPAREN":20,"BracketExpr":21,"LBRACKET":22,"RBRACKET":23,"SlotBracketExpr":24,"LBRACE":25,"RBRACE":26,"GENERIC":27,"COMMA":28,"DOT":29,"COLON":30,"ID":31,"DECIMAL":32,"THIS":33,"Defer":34,"SlotAtom":35,"SlotAtomList":36,"Slot":37,"DEFER":38,"SlotListOpt":39,"SlotList":40,"Expr":41,"ExprStatement":42,"SEMICOLON":43,"Statement":44,"Block":45,"ForStatement":46,"WhileStatement":47,"DoWhileStatement":48,"IfStatement":49,"AwaitStatement":50,"LabeledStatement":51,"ReturnStatement":52,"BreakStatement":53,"ContinueStatement":54,"SwitchStatement":55,"TryStatement":56,"WithStatement":57,"Label":58,"TRY":59,"CatchStatementOpt":60,"FinallyStatementOpt":61,"CATCH":62,"FINALLY":63,"RETURN":64,"CONTINUE":65,"IdOpt":66,"BREAK":67,"WITH":68,"SourceElements":69,"FOR":70,"ForIter":71,"DO":72,"WHILE":73,"SWITCH":74,"CaseBlock":75,"Case":76,"CaseLabel":77,"CaseBody":78,"DEFAULT":79,"CASE":80,"IF":81,"ELSE":82,"FUNCTION":83,"ParamListOpt":84,"AWAIT":85,"ParamList":86,"Param":87,"FunctionBody":88,"ShbangOpt":89,"SHBANG":90,"Program":91,"$accept":0,"$end":1},
@@ -458,7 +459,9 @@ parse: function parse(input) {
return true;
}};/* Jison generated lexer */
-var lexer = (function(){var lexer = ({EOF:1,
+var lexer = (function(){
+
+var lexer = ({EOF:1,
parseError:function parseError(str, hash) {
if (this.yy.parseError) {
this.yy.parseError(str, hash);
View
39 lib/tamejs.js
@@ -5,27 +5,33 @@ var runtime = require ('./runtime').runtime;
var fs = require('fs');
var path = require('path');
var engineVersion = "0.4.3";
+var useCache = true;
exports.runtime = runtime;
//-----------------------------------------------------------------------
function _extension (module, filename) {
-
- var cachePath = path.join(path.dirname(filename), "." +
- path.basename(filename) + "." +
- engineVersion + ".cache");
-
- try {
- var cacheStats = fs.statSync (cachePath);
- } catch(e) { cacheStats = null; }
-
+
var recompile = true;
- if (cacheStats) {
- var tjsStats = fs.statSync(filename);
- if (cacheStats.mtime > tjsStats.mtime){
- recompile = false;
- }
+
+ if (useCache) {
+ var cachePath = path.join(path.dirname(filename), "." +
+ path.basename(filename) + "." +
+ engineVersion + ".cache");
+
+ try {
+ var cacheStats = fs.statSync (cachePath);
+
+ if (cacheStats) {
+ var tjsStats = fs.statSync(filename);
+ if (cacheStats.mtime > tjsStats.mtime &&
+ cacheStats.size > 0){
+ recompile = false;
+ }
+ }
+
+ } catch (e) { cacheStats = null; }
}
var out = "";
@@ -36,7 +42,9 @@ function _extension (module, filename) {
engine.readInputSync ();
engine.parse ();
out = engine.compile ().formatOutput ();
- fs.writeFile(cachePath, out);
+ if (useCache) {
+ fs.writeFileSync(cachePath, out);
+ }
} else {
out = fs.readFileSync(cachePath, 'utf8');
}
@@ -65,6 +73,7 @@ function register (options) {
var ext = "tjs";
if (options.extension) { ext = options.extension; }
+ if (options.disableCache) { useCache = false; }
if (!(ext instanceof Array)) { ext = [ ext ]; }
for (var e in ext) {
require.extensions["." + ext[e]] = _extension;
View
1  meetup.sh
Please sign in to comment.
Something went wrong with that request. Please try again.