Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e4ab641

Browse files
committed
clean up
1 parent ce054e1 commit e4ab641

File tree

2 files changed

+13
-161
lines changed

2 files changed

+13
-161
lines changed

‎PHP.js

Lines changed: 12 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
Released under MIT License
66
*/
77

8-
/*
9-
* @author Niklas von Hertzen <niklas at hertzen.com>
10-
* @created 15.6.2012
11-
* @website http://hertzen.com
12-
*/
13-
14-
158
var PHP = function( code, opts ) {
169

1710
var iniContent = opts.filesystem.readFileSync( "cfg/php.ini" ),
@@ -41,11 +34,7 @@ var PHP = function( code, opts ) {
4134
opts.GET = ( opts.GET !== undefined ) ? PHP.Utils.QueryString( opts.GET ) : {};
4235

4336
opts.FILES = (RAW_POST !== undefined ) ? RAW.Files( opts.ini.upload_max_filesize, opts.ini.max_file_uploads, opts.ini.upload_tmp_dir ) : {};
44-
/*
45-
if (RAW_POST !== undefined ) {
46-
var rawError = RAW.Error();
47-
}
48-
*/
37+
4938
// needs to be called after RAW.Files
5039
if (RAW_POST !== undefined ) {
5140
RAW.WriteFiles( opts.filesystem.writeFileSync );
@@ -55,52 +44,12 @@ var PHP = function( code, opts ) {
5544

5645
this.compiler = new PHP.Compiler( this.AST, opts.SERVER.SCRIPT_FILENAME );
5746

58-
/* if ( false ) {
59-
var thread = new Worker("thread.js");
60-
61-
thread.postMessage({
62-
type: "import",
63-
content: opts.files
64-
});
65-
66-
thread.postMessage({
67-
type: "run",
68-
content: [this.compiler.src, opts]
69-
})
70-
71-
setTimeout(function(){
72-
thread.postMessage({
73-
type: "stop"
74-
})
75-
}, opts.ini.max_execution_time);
76-
77-
78-
thread.addEventListener('message', function(e) {
79-
switch( e.data.type ) {
80-
case "complete":
81-
this.vm = e.data.content;
82-
complete(this);
83-
break;
84-
default:
85-
console.log(e.data);
86-
}
87-
88-
}, false);
89-
return;
90-
}*/
91-
9247
this.vm = new PHP.VM( this.compiler.src, opts );
9348

9449
if (RAW_POST !== undefined ) {
9550
RAW.Error(this.vm[ PHP.Compiler.prototype.ERROR ].bind( this.vm ), opts.SERVER.SCRIPT_FILENAME);
9651
}
9752

98-
/*
99-
if (rawError !== undefined ) {
100-
this.vm[ PHP.Compiler.prototype.ERROR ]( rawError + " in " + opts.SERVER.SCRIPT_FILENAME, PHP.Constants.E_WARNING );
101-
}
102-
*/
103-
10453
this.vm.Run();
10554
};
10655

@@ -373,10 +322,7 @@ PHP.Utils.QueryString = function( str ) {
373322
value = (parts.length > 1 ) ? decodeURIComponent( parts[ 1 ] ) : null,
374323

375324
arrayManager = function( item, parse, value ) {
376-
377-
378325
var arraySearch = parse.match(/^\[([a-z0-9+_\-\[]*)\]/i);
379-
// console.log(item, parse, value, arraySearch);
380326
if ( arraySearch !== null ) {
381327
var key = ( arraySearch[ 1 ] === undefined ) ? Object.keys( item ).length : arraySearch[ 1 ];
382328

@@ -438,7 +384,6 @@ PHP.Utils.QueryString = function( str ) {
438384
}, this);
439385

440386
return items;
441-
442387
};
443388
/*
444389
* @author Niklas von Hertzen <niklas at hertzen.com>
@@ -3306,11 +3251,6 @@ PHP.Modules.prototype.method_exists = function( object, method ) {
33063251
}
33073252

33083253
};
3309-
/*
3310-
* @author Niklas von Hertzen <niklas at hertzen.com>
3311-
* @created 30.6.2012
3312-
* @website http://hertzen.com
3313-
*/
33143254
PHP.Modules.prototype.$foreachInit = function( expr, ctx ) {
33153255

33163256
var COMPILER = PHP.Compiler.prototype,
@@ -3338,14 +3278,14 @@ PHP.Modules.prototype.$foreachInit = function( expr, ctx ) {
33383278
if ( objectValue[ PHP.VM.Class.INTERFACES ].indexOf("Traversable") !== -1 ) {
33393279

33403280
var iterator = objectValue;
3341-
3281+
33423282
try {
33433283
while( (iterator instanceof PHP.VM.ClassPrototype) && iterator[ PHP.VM.Class.INTERFACES ].indexOf("Iterator") === -1 ) {
3344-
iterator = iterator[ COMPILER.METHOD_CALL ]( this, "getIterator" )[ COMPILER.VARIABLE_VALUE ];
3284+
iterator = iterator[ COMPILER.METHOD_CALL ]( this, "getIterator" )[ COMPILER.VARIABLE_VALUE ];
33453285
}
33463286
}catch(e) {
3347-
3348-
}
3287+
3288+
}
33493289
if ( !(iterator instanceof PHP.VM.ClassPrototype) || iterator[ PHP.VM.Class.INTERFACES ].indexOf("Iterator") === -1) {
33503290
this[ COMPILER.ERROR ]( "Objects returned by " + objectValue[ COMPILER.CLASS_NAME ] + "::getIterator() must be traversable or implement interface Iterator", PHP.Constants.E_ERROR, true );
33513291
return;
@@ -3370,28 +3310,28 @@ PHP.Modules.prototype.$foreachInit = function( expr, ctx ) {
33703310

33713311
needReorder = false;
33723312
for (var key in objectValue) {
3373-
3313+
33743314
if ( key.substring(0, classProperty.length ) === classProperty) {
3375-
3315+
33763316
var name = key.substring( classProperty.length );
3377-
3317+
33783318
if (PHP.Utils.Visible.call( this, name, objectValue, ctx )) {
33793319
items.push( name );
33803320
}
33813321

33823322
}
3383-
3323+
33843324
if (((objectValue[ PHP.VM.Class.PROPERTY_TYPE + name ] & PHP.VM.Class.PUBLIC) === PHP.VM.Class.PUBLIC) || objectValue[ PHP.VM.Class.PROPERTY_TYPE + name ] === undefined) {
33853325

3386-
3326+
33873327
} else {
33883328
needReorder = true;
33893329
}
33903330
}
33913331
if ( needReorder ) {
3392-
items.sort();
3332+
items.sort();
33933333
}
3394-
3334+
33953335
return items;
33963336
}.bind(this))( objectValue )
33973337

@@ -3433,52 +3373,25 @@ PHP.Modules.prototype.foreach = function( iterator, byRef, value, key ) {
34333373
}
34343374

34353375
if ( expr[ VAR.TYPE ] === VAR.ARRAY ) {
3436-
3437-
3438-
3439-
/*
3440-
if ( iterator.expr[ VAR.IS_REF ] !== true ) {
3441-
expr = iterator.clone;
3442-
} else {
3443-
expr = expr[ COMPILER.VARIABLE_VALUE ];
3444-
}
3445-
*/
34463376
var clonedValues = iterator.clone[ PHP.VM.Class.PROPERTY + ARRAY.VALUES ][ COMPILER.VARIABLE_VALUE ],
34473377
clonedKeys = iterator.clone[ PHP.VM.Class.PROPERTY + ARRAY.KEYS ][ COMPILER.VARIABLE_VALUE ],
34483378
origValues = expr[ COMPILER.VARIABLE_VALUE ][ PHP.VM.Class.PROPERTY + ARRAY.VALUES ][ COMPILER.VARIABLE_VALUE ],
34493379
origKeys = expr[ COMPILER.VARIABLE_VALUE ][ PHP.VM.Class.PROPERTY + ARRAY.KEYS ][ COMPILER.VARIABLE_VALUE ],
34503380
len = ( byRef === true || iterator.expr[ VAR.IS_REF ] === true ) ? origValues.length : iterator.len,
34513381
pointer = (( byRef === true || iterator.expr[ VAR.IS_REF ] === true) ? expr[ COMPILER.VARIABLE_VALUE ] : iterator.clone )[ PHP.VM.Class.PROPERTY + ARRAY.POINTER];
34523382

3453-
3454-
// clean unset elements off array
3455-
/*
3456-
if ( byRef === true ) {
3457-
origValues.forEach(function( variable, index ) {
3458-
if ( variable[ VAR.DEFINED ] !== true ) {
3459-
origValues.splice( index, 1 );
3460-
origKeys.splice( index, 1 );
3461-
console.log(origValues);
3462-
}
3463-
});
3464-
}*/
3465-
34663383
var compareTo = (byRef === true || iterator.expr[ VAR.IS_REF ] === true) ? origValues : clonedValues,
34673384
result;
34683385

3469-
34703386
var index, lowerLoop = function( index ) {
34713387
while( compareTo [ --index ] === undefined && index > 0 ) {}
34723388
return index;
34733389
}
34743390

3475-
34763391
if ( iterator.breakNext === true) {
3477-
34783392
return false;
34793393
}
34803394

3481-
34823395
if ( pointer[ COMPILER.VARIABLE_VALUE ] !== iterator.count ) {
34833396
if ( iterator.last !== undefined && iterator.last !== compareTo [ pointer[ COMPILER.VARIABLE_VALUE ] ] ) {
34843397
index = pointer[ COMPILER.VARIABLE_VALUE ];
@@ -3601,17 +3514,11 @@ PHP.Modules.prototype.foreach = function( iterator, byRef, value, key ) {
36013514
return true;
36023515
}
36033516
return false;
3604-
36053517
}
3606-
3607-
36083518
} else {
36093519
this[ COMPILER.ERROR ]( "Invalid argument supplied for foreach()", PHP.Constants.E_CORE_WARNING, true );
36103520
return false;
36113521
}
3612-
3613-
3614-
36153522
};
36163523
PHP.Modules.prototype.$include = function( ,ドル $Static, file ) {
36173524

‎src/core.js

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
/*
2-
* @author Niklas von Hertzen <niklas at hertzen.com>
3-
* @created 15.6.2012
4-
* @website http://hertzen.com
5-
*/
6-
7-
81
var PHP = function( code, opts ) {
92

103
var iniContent = opts.filesystem.readFileSync( "cfg/php.ini" ),
@@ -34,11 +27,7 @@ var PHP = function( code, opts ) {
3427
opts.GET = ( opts.GET !== undefined ) ? PHP.Utils.QueryString( opts.GET ) : {};
3528

3629
opts.FILES = (RAW_POST !== undefined ) ? RAW.Files( opts.ini.upload_max_filesize, opts.ini.max_file_uploads, opts.ini.upload_tmp_dir ) : {};
37-
/*
38-
if (RAW_POST !== undefined ) {
39-
var rawError = RAW.Error();
40-
}
41-
*/
30+
4231
// needs to be called after RAW.Files
4332
if (RAW_POST !== undefined ) {
4433
RAW.WriteFiles( opts.filesystem.writeFileSync );
@@ -48,52 +37,12 @@ var PHP = function( code, opts ) {
4837

4938
this.compiler = new PHP.Compiler( this.AST, opts.SERVER.SCRIPT_FILENAME );
5039

51-
/* if ( false ) {
52-
var thread = new Worker("thread.js");
53-
54-
thread.postMessage({
55-
type: "import",
56-
content: opts.files
57-
});
58-
59-
thread.postMessage({
60-
type: "run",
61-
content: [this.compiler.src, opts]
62-
})
63-
64-
setTimeout(function(){
65-
thread.postMessage({
66-
type: "stop"
67-
})
68-
}, opts.ini.max_execution_time);
69-
70-
71-
thread.addEventListener('message', function(e) {
72-
switch( e.data.type ) {
73-
case "complete":
74-
this.vm = e.data.content;
75-
complete(this);
76-
break;
77-
default:
78-
console.log(e.data);
79-
}
80-
81-
}, false);
82-
return;
83-
}*/
84-
8540
this.vm = new PHP.VM( this.compiler.src, opts );
8641

8742
if (RAW_POST !== undefined ) {
8843
RAW.Error(this.vm[ PHP.Compiler.prototype.ERROR ].bind( this.vm ), opts.SERVER.SCRIPT_FILENAME);
8944
}
9045

91-
/*
92-
if (rawError !== undefined ) {
93-
this.vm[ PHP.Compiler.prototype.ERROR ]( rawError + " in " + opts.SERVER.SCRIPT_FILENAME, PHP.Constants.E_WARNING );
94-
}
95-
*/
96-
9746
this.vm.Run();
9847
};
9948

@@ -366,10 +315,7 @@ PHP.Utils.QueryString = function( str ) {
366315
value = (parts.length > 1 ) ? decodeURIComponent( parts[ 1 ] ) : null,
367316

368317
arrayManager = function( item, parse, value ) {
369-
370-
371318
var arraySearch = parse.match(/^\[([a-z0-9+_\-\[]*)\]/i);
372-
// console.log(item, parse, value, arraySearch);
373319
if ( arraySearch !== null ) {
374320
var key = ( arraySearch[ 1 ] === undefined ) ? Object.keys( item ).length : arraySearch[ 1 ];
375321

@@ -431,5 +377,4 @@ PHP.Utils.QueryString = function( str ) {
431377
}, this);
432378

433379
return items;
434-
435380
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /