summaryrefslogtreecommitdiff
path: root/jsstate.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2014-01-17 19:41:41 +0100
committerTor Andersson <tor@ccxvii.net>2014-01-17 19:41:41 +0100
commitf487a7db10164e68f2f7d02d2bdc1f0b1aa2e8ef (patch)
treeda1b784e2640afb45fc9c83cb6cb880acb34cb1d /jsstate.c
parent5ce44f9d4a73250fefc15a6102e60773f7b3b8db (diff)
Set prototype internal property when creating objects.
Diffstat (limited to 'jsstate.c')
-rw-r--r--jsstate.c38
1 files changed, 2 insertions, 36 deletions
diff --git a/jsstate.c b/jsstate.c
index 9c3923a..e3a5f4f 100644
--- a/jsstate.c
+++ b/jsstate.c
@@ -74,49 +74,15 @@ int js_dofile(js_State *J, const char *filename)
return rv;
}
-static int jsB_print(js_State *J, int argc)
-{
- int i;
- for (i = 1; i < argc; ++i) {
- const char *s = js_tostring(J, i);
- if (i > 1) putchar(' ');
- fputs(s, stdout);
- }
- putchar('\n');
- return 0;
-}
-
-static int jsB_eval(js_State *J, int argc)
-{
- const char *s;
-
- if (!js_isstring(J, -1))
- return 1;
-
- // FIXME: return value if eval string is an expression
-
- s = js_tostring(J, -1);
- if (jsR_loadscript(J, "(eval)", s))
- jsR_error(J, "SyntaxError (eval)");
-
- js_dup(J, 0); /* copy this */
- js_call(J, 0);
- return 1;
-}
-
js_State *js_newstate(void)
{
js_State *J = malloc(sizeof *J);
memset(J, 0, sizeof(*J));
- J->G = jsR_newobject(J, JS_COBJECT);
+ J->G = jsR_newobject(J, JS_COBJECT, NULL);
J->E = jsR_newenvironment(J, J->G, NULL);
- js_pushcfunction(J, jsB_eval);
- js_setglobal(J, "eval");
-
- js_pushcfunction(J, jsB_print);
- js_setglobal(J, "print");
+ jsB_init(J);
return J;
}