From 0edd9b9fc60440213e4df926ea511419ee291f1e Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 15 Jun 2018 22:12:03 -0700 Subject: 4257 - abortive attempt at safe fat pointers I've been working on this slowly over several weeks, but it's too hard to support 0 as the null value for addresses. I constantly have to add exceptions for scalar value corresponding to an address type (now occupying 2 locations). The final straw is the test for 'reload': x:num <- reload text 'reload' returns an address. But there's no way to know that for arbitrary instructions. New plan: let's put this off for a bit and first create support for literals. Then use 'null' instead of '0' for addresses everywhere. Then it'll be easy to just change what 'null' means. --- 027call_ingredient.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to '027call_ingredient.cc') diff --git a/027call_ingredient.cc b/027call_ingredient.cc index 46fafe7e..00e44ea3 100644 --- a/027call_ingredient.cc +++ b/027call_ingredient.cc @@ -68,6 +68,9 @@ case NEXT_INGREDIENT: { } products.push_back( current_call().ingredient_atoms.at(current_call().next_ingredient_to_process)); + if (is_mu_scalar(current_call().ingredients.at(current_call().next_ingredient_to_process)) + && is_mu_address(current_instruction().products.at(0))) + products.at(0).insert(products.at(0).begin(), /*alloc id*/0); assert(SIZE(products) == 1); products.resize(2); // push a new vector products.at(1).push_back(1); ++current_call().next_ingredient_to_process; @@ -94,6 +97,18 @@ def f [ ] +error: f: no ingredient to save in '11:num' +:(scenario pass_null_ingredient_for_address) +def main [ + f 0 +] +def f [ + 1:address:num <- next-ingredient +] ++mem: storing 0 in location 2 +$error: 0 + +//: another primitive: 'rewind-ingredients' to rescan ingredients from the start + :(scenario rewind_ingredients) def main [ f 2 @@ -124,6 +139,8 @@ case REWIND_INGREDIENTS: { break; } +//: another primitive: 'ingredient' for random access + :(scenario ingredient) def main [ f 1, 2 -- cgit 1.4.1-2-gfad0 816888837603fa6c'/>
path: root/cpp/.traces/reply
blob: de83831a0d1f17232a8076eab64b680480ae2fa4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
parse/0: instruction: f
parse/0:   ingredient: {name: "2", value: 0, type: 0, properties: ["2": "literal"]}
parse/0:   product: {name: "3", value: 0, type: 1, properties: ["3": "integer"]}
parse/0:   product: {name: "4", value: 0, type: 1, properties: ["4": "integer"]}
parse/0: instruction: next-ingredient
parse/0:   product: {name: "12", value: 0, type: 1, properties: ["12": "integer"]}
parse/0: instruction: add
parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: ["1": "literal"]}
parse/0:   ingredient: {name: "12", value: 0, type: 1, properties: ["12": "integer"]}
parse/0:   product: {name: "13", value: 0, type: 1, properties: ["13": "integer"]}
parse/0: instruction: reply
parse/0:   ingredient: {name: "12", value: 0, type: 1, properties: ["12": "integer"]}
parse/0:   ingredient: {name: "13", value: 0, type: 1, properties: ["13": "integer"]}
after-brace/0: recipe main
after-brace/0: f ...
after-brace/0: recipe f
after-brace/0: next-ingredient ...
after-brace/0: add ...
after-brace/0: reply ...
new/0: routine allocated memory from 1000 to 101000
schedule/0: main
run/0: instruction main/0
run/0: {name: "3", value: 3, type: 1, properties: ["3": "integer"]}, {name: "4", value: 4, type: 1, properties: ["4": "integer"]} <- f {name: "2", value: 2, type: 0, properties: ["2": "literal"]}
run/0: instruction f/0
run/0: {name: "12", value: 12, type: 1, properties: ["12": "integer"]} <- next-ingredient 
run/0: product 0 is 2
mem/0: storing 2 in location 12
run/0: instruction f/1
run/0: {name: "13", value: 13, type: 1, properties: ["13": "integer"]} <- add {name: "1", value: 1, type: 0, properties: ["1": "literal"]}, {name: "12", value: 12, type: 1, properties: ["12": "integer"]}
run/0: ingredient 0 is 1
run/0: ingredient 1 is 12
mem/0: location 12 is 2
run/0: product 0 is 3
mem/0: storing 3 in location 13
run/0: instruction f/2
run/0: reply {name: "12", value: 12, type: 1, properties: ["12": "integer"]}, {name: "13", value: 13, type: 1, properties: ["13": "integer"]}
mem/0: location 12 is 2
mem/0: location 13 is 3
run/0: result 0 is 2
mem/0: storing 2 in location 3
run/0: result 1 is 3
mem/0: storing 3 in location 4