comparison src/c/urweb.c @ 970:8371d12ae63f

Hopefully complete refactoring of Jscomp to output ASTs; partial implementation of interpreter in runtime system (demo/alert works)
author Adam Chlipala <adamc@hcoop.net>
date Tue, 22 Sep 2009 12:23:21 -0400
parents 53b9aeac676c
children 733f67bb64e7
comparison
equal deleted inserted replaced
969:001edfbe2561 970:8371d12ae63f
1284 1284
1285 uw_Basis_int uw_Basis_new_client_source(uw_context ctx, uw_Basis_string s) { 1285 uw_Basis_int uw_Basis_new_client_source(uw_context ctx, uw_Basis_string s) {
1286 int len; 1286 int len;
1287 size_t s_len = strlen(s); 1287 size_t s_len = strlen(s);
1288 1288
1289 uw_check_script(ctx, 12 + INTS_MAX + s_len); 1289 uw_check_script(ctx, 18 + INTS_MAX + s_len);
1290 sprintf(ctx->script.front, "var s%d=sc(%n", ctx->source_count, &len); 1290 sprintf(ctx->script.front, "var s%d=sc(exec(%n", ctx->source_count, &len);
1291 ctx->script.front += len; 1291 ctx->script.front += len;
1292 strcpy(ctx->script.front, s); 1292 strcpy(ctx->script.front, s);
1293 ctx->script.front += s_len; 1293 ctx->script.front += s_len;
1294 strcpy(ctx->script.front, ");"); 1294 strcpy(ctx->script.front, "));");
1295 ctx->script.front += 2; 1295 ctx->script.front += 2;
1296 1296
1297 return ctx->source_count++; 1297 return ctx->source_count++;
1298 } 1298 }
1299 1299
1300 uw_unit uw_Basis_set_client_source(uw_context ctx, uw_Basis_int n, uw_Basis_string s) { 1300 uw_unit uw_Basis_set_client_source(uw_context ctx, uw_Basis_int n, uw_Basis_string s) {
1301 int len; 1301 int len;
1302 size_t s_len = strlen(s); 1302 size_t s_len = strlen(s);
1303 1303
1304 uw_check_script(ctx, 6 + INTS_MAX + s_len); 1304 uw_check_script(ctx, 12 + INTS_MAX + s_len);
1305 sprintf(ctx->script.front, "sv(s%d,%n", (int)n, &len); 1305 sprintf(ctx->script.front, "sv(s%d,exec(%n", (int)n, &len);
1306 ctx->script.front += len; 1306 ctx->script.front += len;
1307 strcpy(ctx->script.front, s); 1307 strcpy(ctx->script.front, s);
1308 ctx->script.front += s_len; 1308 ctx->script.front += s_len;
1309 strcpy(ctx->script.front, ");"); 1309 strcpy(ctx->script.front, "));");
1310 ctx->script.front += 2; 1310 ctx->script.front += 2;
1311 1311
1312 return uw_unit_v; 1312 return uw_unit_v;
1313 } 1313 }
1314 1314