| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "vm/ast_printer.h" | 6 #include "vm/ast_printer.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/longjump.h" | 9 #include "vm/longjump.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 " }\n" | 256 " }\n" |
| 257 " return f(22);\n" | 257 " return f(22);\n" |
| 258 "}\n"; | 258 "}\n"; |
| 259 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 259 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 260 EXPECT_VALID(lib); | 260 EXPECT_VALID(lib); |
| 261 EXPECT_STREQ( | 261 EXPECT_STREQ( |
| 262 // function f uses one ctx var at (0); doesn't save ctx. | 262 // function f uses one ctx var at (0); doesn't save ctx. |
| 263 "::.main_f\n" | 263 "::.main_f\n" |
| 264 " 0 ContextVar level=0 begin=14 end=28 name=value\n" | 264 " 0 ContextVar level=0 begin=14 end=28 name=value\n" |
| 265 " 1 StackVar scope=1 begin=16 end=28 name=param\n" | 265 " 1 StackVar scope=1 begin=16 end=28 name=param\n" |
| 266 " 2 CurrentCtx scope=0 begin=0 end=0" |
| 267 " name=:current_context_var\n" |
| 266 | 268 |
| 267 // Closure call saves current context. | 269 // Closure call saves current context. |
| 268 "(dynamic, dynamic) => int.call\n" | 270 "(dynamic, dynamic) => int.call\n" |
| 269 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 271 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 270 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 272 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 271 " name=:saved_current_context_var\n" | 273 " name=:current_context_var\n" |
| 272 | 274 |
| 273 // function main uses one ctx var at (1); saves caller ctx. | 275 // function main uses one ctx var at (1); saves caller ctx. |
| 274 "::.main\n" | 276 "::.main\n" |
| 275 " 0 ContextLevel level=1 scope=1 begin=2 end=37\n" | 277 " 0 ContextLevel level=1 scope=1 begin=2 end=37\n" |
| 276 " 1 SavedEntryCtx scope=0 begin=0 end=0" | 278 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 279 " name=:current_context_var\n" |
| 280 " 2 SavedEntryCtx scope=0 begin=0 end=0" |
| 277 " name=:saved_entry_context_var\n" | 281 " name=:saved_entry_context_var\n" |
| 278 " 2 ContextVar level=1 begin=7 end=37 name=value\n" | 282 " 3 ContextVar level=1 begin=7 end=37 name=value\n" |
| 279 " 3 StackVar scope=2 begin=12 end=37 name=f\n", | 283 " 4 StackVar scope=2 begin=12 end=37 name=f\n", |
| 280 CaptureVarsAtLine(lib, "main", 4)); | 284 CaptureVarsAtLine(lib, "main", 4)); |
| 281 } | 285 } |
| 282 | 286 |
| 283 | 287 |
| 284 TEST_CASE(Parser_AllocateVariables_NestedCapturedVar) { | 288 TEST_CASE(Parser_AllocateVariables_NestedCapturedVar) { |
| 285 const char* kScriptChars = | 289 const char* kScriptChars = |
| 286 "int a() {\n" | 290 "int a() {\n" |
| 287 " int b() {\n" | 291 " int b() {\n" |
| 288 " var value = 11;\n" | 292 " var value = 11;\n" |
| 289 " int c() {\n" | 293 " int c() {\n" |
| 290 " return value;\n" // line 5 | 294 " return value;\n" // line 5 |
| 291 " }\n" | 295 " }\n" |
| 292 " return c();\n" | 296 " return c();\n" |
| 293 " }\n" | 297 " }\n" |
| 294 " return b();\n" | 298 " return b();\n" |
| 295 "}\n"; | 299 "}\n"; |
| 296 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 300 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 297 EXPECT_VALID(lib); | 301 EXPECT_VALID(lib); |
| 298 EXPECT_STREQ( | 302 EXPECT_STREQ( |
| 299 // Innermost function uses captured variable 'value' from middle | 303 // Innermost function uses captured variable 'value' from middle |
| 300 // function. | 304 // function. |
| 301 "::.a_b_c\n" | 305 "::.a_b_c\n" |
| 302 " 0 ContextVar level=0 begin=20 end=30 name=value\n" | 306 " 0 ContextVar level=0 begin=20 end=30 name=value\n" |
| 307 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 308 " name=:current_context_var\n" |
| 303 | 309 |
| 304 // Closure call saves current context. | 310 // Closure call saves current context. |
| 305 "(dynamic) => int.call\n" | 311 "(dynamic) => int.call\n" |
| 306 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 312 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 307 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 313 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 308 " name=:saved_current_context_var\n" | 314 " name=:current_context_var\n" |
| 309 | 315 |
| 310 // Middle function saves the entry context. Notice that this | 316 // Middle function saves the entry context. Notice that this |
| 311 // happens here and not in the outermost function. We always | 317 // happens here and not in the outermost function. We always |
| 312 // save the entry context at the last possible moment. | 318 // save the entry context at the last possible moment. |
| 313 "::.a_b\n" | 319 "::.a_b\n" |
| 314 " 0 ContextLevel level=1 scope=1 begin=8 end=38\n" | 320 " 0 ContextLevel level=1 scope=1 begin=8 end=38\n" |
| 315 " 1 SavedEntryCtx scope=0 begin=0 end=0" | 321 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 322 " name=:current_context_var\n" |
| 323 " 2 SavedEntryCtx scope=0 begin=0 end=0" |
| 316 " name=:saved_entry_context_var\n" | 324 " name=:saved_entry_context_var\n" |
| 317 " 2 ContextVar level=1 begin=13 end=38 name=value\n" | 325 " 3 ContextVar level=1 begin=13 end=38 name=value\n" |
| 318 " 3 StackVar scope=2 begin=18 end=38 name=c\n" | 326 " 4 StackVar scope=2 begin=18 end=38 name=c\n" |
| 319 | 327 |
| 320 // Closure call saves current context. | 328 // Closure call saves current context. |
| 321 "(dynamic) => int.call\n" | 329 "(dynamic) => int.call\n" |
| 322 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 330 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 323 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 331 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 324 " name=:saved_current_context_var\n" | 332 " name=:current_context_var\n" |
| 325 | 333 |
| 326 // Outermost function neglects to save the entry context. We | 334 // Outermost function neglects to save the entry context. We |
| 327 // don't save the entry context if the function has no captured | 335 // don't save the entry context if the function has no captured |
| 328 // variables. | 336 // variables. |
| 329 "::.a\n" | 337 "::.a\n" |
| 330 " 0 StackVar scope=2 begin=6 end=46 name=b\n", | 338 " 0 CurrentCtx scope=0 begin=0 end=0" |
| 339 " name=:current_context_var\n" |
| 340 " 1 StackVar scope=2 begin=6 end=46 name=b\n", |
| 331 CaptureVarsAtLine(lib, "a", 5)); | 341 CaptureVarsAtLine(lib, "a", 5)); |
| 332 } | 342 } |
| 333 | 343 |
| 334 | 344 |
| 335 TEST_CASE(Parser_AllocateVariables_TwoChains) { | 345 TEST_CASE(Parser_AllocateVariables_TwoChains) { |
| 336 const char* kScriptChars = | 346 const char* kScriptChars = |
| 337 "int a() {\n" | 347 "int a() {\n" |
| 338 " var value1 = 11;\n" | 348 " var value1 = 11;\n" |
| 339 " int b() {\n" | 349 " int b() {\n" |
| 340 " int aa() {\n" | 350 " int aa() {\n" |
| 341 " var value2 = 12;\n" | 351 " var value2 = 12;\n" |
| 342 " int bb() {\n" | 352 " int bb() {\n" |
| 343 " return value2;\n" // line 7 | 353 " return value2;\n" // line 7 |
| 344 " }\n" | 354 " }\n" |
| 345 " return bb();\n" | 355 " return bb();\n" |
| 346 " }\n" | 356 " }\n" |
| 347 " return value1 + aa();\n" | 357 " return value1 + aa();\n" |
| 348 " }\n" | 358 " }\n" |
| 349 " return b();\n" | 359 " return b();\n" |
| 350 "}\n"; | 360 "}\n"; |
| 351 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 361 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 352 EXPECT_VALID(lib); | 362 EXPECT_VALID(lib); |
| 363 |
| 353 EXPECT_STREQ( | 364 EXPECT_STREQ( |
| 354 // bb captures only value2 from aa. No others. | 365 // bb captures only value2 from aa. No others. |
| 355 "::.a_b_aa_bb\n" | 366 "::.a_b_aa_bb\n" |
| 356 " 0 ContextVar level=0 begin=32 end=42 name=value2\n" | 367 " 0 ContextVar level=0 begin=32 end=42 name=value2\n" |
| 368 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 369 " name=:current_context_var\n" |
| 357 | 370 |
| 358 // Closure call saves current context. | 371 // Closure call saves current context. |
| 359 "(dynamic) => int.call\n" | 372 "(dynamic) => int.call\n" |
| 360 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 373 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 361 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 374 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 362 " name=:saved_current_context_var\n" | 375 " name=:current_context_var\n" |
| 363 | 376 |
| 364 // aa shares value2. Notice that we save the entry ctx instead | 377 // aa shares value2. Notice that we save the entry ctx instead |
| 365 // of chaining from b. This keeps us from holding onto closures | 378 // of chaining from b. This keeps us from holding onto closures |
| 366 // that we would never access. | 379 // that we would never access. |
| 367 "::.a_b_aa\n" | 380 "::.a_b_aa\n" |
| 368 " 0 ContextLevel level=1 scope=1 begin=20 end=50\n" | 381 " 0 ContextLevel level=1 scope=1 begin=20 end=50\n" |
| 369 " 1 SavedEntryCtx scope=0 begin=0 end=0" | 382 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 383 " name=:current_context_var\n" |
| 384 " 2 SavedEntryCtx scope=0 begin=0 end=0" |
| 370 " name=:saved_entry_context_var\n" | 385 " name=:saved_entry_context_var\n" |
| 371 " 2 ContextVar level=1 begin=25 end=50 name=value2\n" | 386 " 3 ContextVar level=1 begin=25 end=50 name=value2\n" |
| 372 " 3 StackVar scope=2 begin=30 end=50 name=bb\n" | 387 " 4 StackVar scope=2 begin=30 end=50 name=bb\n" |
| 373 | 388 |
| 374 // Closure call saves current context. | 389 // Closure call saves current context. |
| 375 "(dynamic) => int.call\n" | 390 "(dynamic) => int.call\n" |
| 376 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 391 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 377 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 392 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 378 " name=:saved_current_context_var\n" | 393 " name=:current_context_var\n" |
| 379 | 394 |
| 380 // b captures value1 from a. | 395 // b captures value1 from a. |
| 381 "::.a_b\n" | 396 "::.a_b\n" |
| 382 " 0 ContextVar level=0 begin=14 end=60 name=value1\n" | 397 " 0 ContextVar level=0 begin=14 end=60 name=value1\n" |
| 383 " 1 StackVar scope=2 begin=18 end=60 name=aa\n" | 398 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 399 " name=:current_context_var\n" |
| 400 " 2 StackVar scope=2 begin=18 end=60 name=aa\n" |
| 384 | 401 |
| 385 // Closure call saves current context. | 402 // Closure call saves current context. |
| 386 "(dynamic) => int.call\n" | 403 "(dynamic) => int.call\n" |
| 387 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 404 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 388 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 405 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 389 " name=:saved_current_context_var\n" | 406 " name=:current_context_var\n" |
| 390 | 407 |
| 391 // a shares value1, saves entry ctx. | 408 // a shares value1, saves entry ctx. |
| 392 "::.a\n" | 409 "::.a\n" |
| 393 " 0 ContextLevel level=1 scope=1 begin=2 end=68\n" | 410 " 0 ContextLevel level=1 scope=1 begin=2 end=68\n" |
| 394 " 1 SavedEntryCtx scope=0 begin=0 end=0" | 411 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 412 " name=:current_context_var\n" |
| 413 " 2 SavedEntryCtx scope=0 begin=0 end=0" |
| 395 " name=:saved_entry_context_var\n" | 414 " name=:saved_entry_context_var\n" |
| 396 " 2 ContextVar level=1 begin=7 end=68 name=value1\n" | 415 " 3 ContextVar level=1 begin=7 end=68 name=value1\n" |
| 397 " 3 StackVar scope=2 begin=12 end=68 name=b\n", | 416 " 4 StackVar scope=2 begin=12 end=68 name=b\n", |
| 398 CaptureVarsAtLine(lib, "a", 7)); | 417 CaptureVarsAtLine(lib, "a", 7)); |
| 399 } | 418 } |
| 400 | 419 |
| 401 | 420 |
| 402 TEST_CASE(Parser_AllocateVariables_Issue7681) { | 421 TEST_CASE(Parser_AllocateVariables_Issue7681) { |
| 403 // This is a distilled version of the program from Issue 7681. | 422 // This is a distilled version of the program from Issue 7681. |
| 404 // | 423 // |
| 405 // When we create the closure at line 11, we need to make sure to | 424 // When we create the closure at line 11, we need to make sure to |
| 406 // save the entry context instead of chaining to the parent context. | 425 // save the entry context instead of chaining to the parent context. |
| 407 // | 426 // |
| (...skipping 17 matching lines...) Expand all Loading... |
| 425 " };\n" | 444 " };\n" |
| 426 " x.onX(new Y());\n" | 445 " x.onX(new Y());\n" |
| 427 "}\n"; | 446 "}\n"; |
| 428 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 447 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 429 EXPECT_VALID(lib); | 448 EXPECT_VALID(lib); |
| 430 EXPECT_STREQ( | 449 EXPECT_STREQ( |
| 431 // This frame saves the entry context instead of chaining. Good. | 450 // This frame saves the entry context instead of chaining. Good. |
| 432 "::.doIt_<anonymous closure>\n" | 451 "::.doIt_<anonymous closure>\n" |
| 433 " 0 ContextLevel level=1 scope=1 begin=41 end=62\n" | 452 " 0 ContextLevel level=1 scope=1 begin=41 end=62\n" |
| 434 " 1 ContextVar level=1 begin=42 end=62 name=y\n" | 453 " 1 ContextVar level=1 begin=42 end=62 name=y\n" |
| 435 " 2 SavedEntryCtx scope=0 begin=0 end=0" | 454 " 2 CurrentCtx scope=0 begin=0 end=0" |
| 455 " name=:current_context_var\n" |
| 456 " 3 SavedEntryCtx scope=0 begin=0 end=0" |
| 436 " name=:saved_entry_context_var\n" | 457 " name=:saved_entry_context_var\n" |
| 437 | 458 |
| 438 // Closure call saves current context. | 459 // Closure call saves current context. |
| 439 "(dynamic, dynamic) => dynamic.call\n" | 460 "(dynamic, dynamic) => dynamic.call\n" |
| 440 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 461 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 441 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 462 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 442 " name=:saved_current_context_var\n" | 463 " name=:current_context_var\n" |
| 443 | 464 |
| 444 "X.onX\n" | 465 "X.onX\n" |
| 445 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 466 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 467 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 468 " name=:current_context_var\n" |
| 446 | 469 |
| 447 // No context is saved here since no vars are captured. | 470 // No context is saved here since no vars are captured. |
| 448 "::.doIt\n" | 471 "::.doIt\n" |
| 449 " 0 StackVar scope=2 begin=29 end=77 name=x\n", | 472 " 0 CurrentCtx scope=0 begin=0 end=0" |
| 473 " name=:current_context_var\n" |
| 474 " 1 StackVar scope=2 begin=29 end=77 name=x\n", |
| 450 CaptureVarsAtLine(lib, "doIt", 12)); | 475 CaptureVarsAtLine(lib, "doIt", 12)); |
| 451 } | 476 } |
| 452 | 477 |
| 453 | 478 |
| 454 TEST_CASE(Parser_AllocateVariables_CaptureLoopVar) { | 479 TEST_CASE(Parser_AllocateVariables_CaptureLoopVar) { |
| 455 // This test verifies that... | 480 // This test verifies that... |
| 456 // | 481 // |
| 457 // https://code.google.com/p/dart/issues/detail?id=18561 | 482 // https://code.google.com/p/dart/issues/detail?id=18561 |
| 458 // | 483 // |
| 459 // ...stays fixed. | 484 // ...stays fixed. |
| 460 const char* kScriptChars = | 485 const char* kScriptChars = |
| 461 "int outer() {\n" | 486 "int outer() {\n" |
| 462 " for(int i = 0; i < 1; i++) {\n" | 487 " for(int i = 0; i < 1; i++) {\n" |
| 463 " var value = 11 + i;\n" | 488 " var value = 11 + i;\n" |
| 464 " int inner() {\n" | 489 " int inner() {\n" |
| 465 " return value;\n" // line 5 | 490 " return value;\n" // line 5 |
| 466 " }\n" | 491 " }\n" |
| 467 " return inner();\n" | 492 " return inner();\n" |
| 468 " }\n" | 493 " }\n" |
| 469 "}\n"; | 494 "}\n"; |
| 470 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 495 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 471 EXPECT_VALID(lib); | 496 EXPECT_VALID(lib); |
| 472 EXPECT_STREQ( | 497 EXPECT_STREQ( |
| 473 // inner function captures variable value. That's fine. | 498 // inner function captures variable value. That's fine. |
| 474 "::.outer_inner\n" | 499 "::.outer_inner\n" |
| 475 " 0 ContextVar level=0 begin=32 end=42 name=value\n" | 500 " 0 ContextVar level=0 begin=32 end=42 name=value\n" |
| 501 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 502 " name=:current_context_var\n" |
| 476 | 503 |
| 477 // Closure call saves current context. | 504 // Closure call saves current context. |
| 478 "(dynamic) => int.call\n" | 505 "(dynamic) => int.call\n" |
| 479 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 506 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 480 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 507 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 481 " name=:saved_current_context_var\n" | 508 " name=:current_context_var\n" |
| 482 | 509 |
| 483 // The outer function saves the entry context, even though the | 510 // The outer function saves the entry context, even though the |
| 484 // captured variable is in a loop. Good. | 511 // captured variable is in a loop. Good. |
| 485 "::.outer\n" | 512 "::.outer\n" |
| 486 " 0 SavedEntryCtx scope=0 begin=0 end=0" | 513 " 0 CurrentCtx scope=0 begin=0 end=0" |
| 514 " name=:current_context_var\n" |
| 515 " 1 SavedEntryCtx scope=0 begin=0 end=0" |
| 487 " name=:saved_entry_context_var\n" | 516 " name=:saved_entry_context_var\n" |
| 488 " 1 StackVar scope=3 begin=9 end=50 name=i\n" | 517 " 2 StackVar scope=3 begin=9 end=50 name=i\n" |
| 489 " 2 ContextLevel level=1 scope=4 begin=20 end=50\n" | 518 " 3 ContextLevel level=1 scope=4 begin=20 end=50\n" |
| 490 " 3 ContextVar level=1 begin=23 end=50 name=value\n" | 519 " 4 ContextVar level=1 begin=23 end=50 name=value\n" |
| 491 " 4 StackVar scope=4 begin=30 end=50 name=inner\n", | 520 " 5 StackVar scope=4 begin=30 end=50 name=inner\n", |
| 492 CaptureVarsAtLine(lib, "outer", 5)); | 521 CaptureVarsAtLine(lib, "outer", 5)); |
| 493 } | 522 } |
| 494 | 523 |
| 495 TEST_CASE(Parser_AllocateVariables_MiddleChain) { | 524 TEST_CASE(Parser_AllocateVariables_MiddleChain) { |
| 496 const char* kScriptChars = | 525 const char* kScriptChars = |
| 497 "a() {\n" | 526 "a() {\n" |
| 498 " int x = 11;\n" | 527 " int x = 11;\n" |
| 499 " b() {\n" | 528 " b() {\n" |
| 500 " for (int i = 0; i < 1; i++) {\n" | 529 " for (int i = 0; i < 1; i++) {\n" |
| 501 " int d() {\n" | 530 " int d() {\n" |
| 502 " return i;\n" | 531 " return i;\n" |
| 503 " }\n" | 532 " }\n" |
| 504 " }\n" | 533 " }\n" |
| 505 " int c() {\n" | 534 " int c() {\n" |
| 506 " return x + 1;\n" // line 10 | 535 " return x + 1;\n" // line 10 |
| 507 " }\n" | 536 " }\n" |
| 508 " return c();\n" | 537 " return c();\n" |
| 509 " }\n" | 538 " }\n" |
| 510 " return b();\n" | 539 " return b();\n" |
| 511 "}\n"; | 540 "}\n"; |
| 512 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 541 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 513 EXPECT_VALID(lib); | 542 EXPECT_VALID(lib); |
| 514 EXPECT_STREQ( | 543 EXPECT_STREQ( |
| 515 "::.a_b_c\n" | 544 "::.a_b_c\n" |
| 516 " 0 ContextVar level=0 begin=48 end=60 name=x\n" | 545 " 0 ContextVar level=0 begin=48 end=60 name=x\n" |
| 546 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 547 " name=:current_context_var\n" |
| 517 "(dynamic) => int.call\n" | 548 "(dynamic) => int.call\n" |
| 518 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 549 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 519 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 550 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 520 " name=:saved_current_context_var\n" | 551 " name=:current_context_var\n" |
| 521 | 552 |
| 522 // Doesn't save the entry context. Chains to parent instead. | 553 // Doesn't save the entry context. Chains to parent instead. |
| 523 "::.a_b\n" | 554 "::.a_b\n" |
| 524 " 0 ContextVar level=0 begin=12 end=68 name=x\n" | 555 " 0 ContextVar level=0 begin=12 end=68 name=x\n" |
| 525 " 1 StackVar scope=2 begin=46 end=68 name=c\n" | 556 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 526 " 2 ContextLevel level=1 scope=3 begin=18 end=46\n" | 557 " name=:current_context_var\n" |
| 527 " 3 ContextVar level=1 begin=19 end=46 name=i\n" | 558 " 2 StackVar scope=2 begin=46 end=68 name=c\n" |
| 528 " 4 StackVar scope=4 begin=32 end=46 name=d\n" | 559 " 3 ContextLevel level=1 scope=3 begin=18 end=46\n" |
| 560 " 4 ContextVar level=1 begin=19 end=46 name=i\n" |
| 561 " 5 StackVar scope=4 begin=32 end=46 name=d\n" |
| 529 | 562 |
| 530 "(dynamic) => dynamic.call\n" | 563 "(dynamic) => dynamic.call\n" |
| 531 " 0 StackVar scope=1 begin=0 end=0 name=this\n" | 564 " 0 StackVar scope=1 begin=0 end=0 name=this\n" |
| 532 " 1 SavedCurrentCtx scope=0 begin=0 end=0" | 565 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 533 " name=:saved_current_context_var\n" | 566 " name=:current_context_var\n" |
| 534 | 567 |
| 535 "::.a\n" | 568 "::.a\n" |
| 536 " 0 ContextLevel level=1 scope=1 begin=1 end=76\n" | 569 " 0 ContextLevel level=1 scope=1 begin=1 end=76\n" |
| 537 " 1 SavedEntryCtx scope=0 begin=0 end=0" | 570 " 1 CurrentCtx scope=0 begin=0 end=0" |
| 571 " name=:current_context_var\n" |
| 572 " 2 SavedEntryCtx scope=0 begin=0 end=0" |
| 538 " name=:saved_entry_context_var\n" | 573 " name=:saved_entry_context_var\n" |
| 539 " 2 ContextVar level=1 begin=6 end=76 name=x\n" | 574 " 3 ContextVar level=1 begin=6 end=76 name=x\n" |
| 540 " 3 StackVar scope=2 begin=11 end=76 name=b\n", | 575 " 4 StackVar scope=2 begin=11 end=76 name=b\n", |
| 541 CaptureVarsAtLine(lib, "a", 10)); | 576 CaptureVarsAtLine(lib, "a", 10)); |
| 542 } | 577 } |
| 543 | 578 |
| 544 } // namespace dart | 579 } // namespace dart |
| OLD | NEW |