Skip to content

Commit

Permalink
remove $object->type
Browse files Browse the repository at this point in the history
  • Loading branch information
sstur committed Sep 13, 2014
1 parent 47b8a1e commit 263b777
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
11 changes: 5 additions & 6 deletions +notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ node js2php tests.js>test/tests.php && php -f test/tests.php
rsync -av ../js2php dev:~/

Divergence from JavaScript
Not Implemented:
"0" -> truthy
function.length
arguments.caller
Implicitly setting globals
eval or new Function(string)
function.length
"0" -> truthy
cannot implicitly set global
doesn't throw on use of undeclared var
no runtime parsing: eval, new Function()

Compiling:
keyword literals: null -> Null::$null, undefined -> null
Expand Down
7 changes: 3 additions & 4 deletions +todo.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
operators: negate, unary_plus, bitwise, ...
operators: unary_plus, bitwise, ...
unicode: all string functions should use mb_
demo: form post
bug: starting a function declaration on first line doesn't compile
refactor js assert out of test folder
this used in global context should return global
remove $object->type
x_negate(numeric_literal)
toPHPString -> utils; should escape "{$a->b}"
all $this_->data should use get and length should use to_number
all $this_->data should use get; length should use to_number
Object should provide unset (overriden for Global)
throw on use undeclared var
build should not log "Success"

Error Handling
throw new Exception("TypeError: %s is not a function")
Expand Down
1 change: 0 additions & 1 deletion php/classes/Function.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
class Func extends Object {
public $name = "";
public $type = "function";
public $className = "[object Function]";
public $bound = null;

Expand Down
1 change: 0 additions & 1 deletion php/classes/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
class Object implements JsonSerializable {
public $data = null;
public $proto = null;
public $type = "object";
public $className = "[object Object]";

static $protoObject = null;
Expand Down
5 changes: 4 additions & 1 deletion php/helpers/operators.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ function x_typeof($value) {
if ($type === 'string' || $type === 'boolean') {
return $type;
}
if ($value instanceof Func) {
return 'function';
}
if ($value instanceof Object) {
return $value->type;
return 'object';
}
return 'unknown';
}

0 comments on commit 263b777

Please sign in to comment.