@@ -36,47 +36,50 @@ some PAST that will produce it or a name that it can be looked up by.
36
36
.const int STORAGE_SPEC_BP_NUM = 2
37
37
.const int STORAGE_SPEC_BP_STR = 3
38
38
39
- . sub ' attribute_6model ' :method : multi ( _ , [ ' PAST ' ; ' Var ' ])
39
+ . sub ' attribute_6model_type ' :method
40
40
.param pmc node
41
- .param pmc bindpost
42
41
43
- .local pmc ops
44
- $P0 = get_hll_global [' POST' ], ' Ops'
45
- ops = $P0 . ' new' (' node' = >node )
46
- .local string name
47
- name = node . ' name' ()
48
- name = self . ' escape' (name )
49
-
50
42
# See if we have a type. If so, use it to determine what op to use
51
43
# and what the register type will be.
52
44
.local pmc type
53
- .local string get_attr_op , set_attr_op , coerce_reg_type
54
45
.local int primitive_type_id
55
46
type = node . ' type' ()
56
47
primitive_type_id = repr_get_primitive_type_spec type
57
48
if primitive_type_id == STORAGE_SPEC_BP_INT goto prim_int
58
49
if primitive_type_id == STORAGE_SPEC_BP_NUM goto prim_num
59
50
if primitive_type_id == STORAGE_SPEC_BP_STR goto prim_str
60
- get_attr_op = ' getattribute'
61
- set_attr_op = ' setattribute'
62
- coerce_reg_type = ' P'
63
- goto type_done
51
+ .return (' P' , ' getattribute' , ' setattribute' )
64
52
prim_int:
65
- get_attr_op = ' repr_get_attr_int'
66
- set_attr_op = ' repr_bind_attr_int'
67
- coerce_reg_type = ' I'
68
- goto type_done
53
+ .return (' i' , ' repr_get_attr_int' , ' repr_bind_attr_int' )
69
54
prim_num:
70
- get_attr_op = ' repr_get_attr_num'
71
- set_attr_op = ' repr_bind_attr_num'
72
- coerce_reg_type = ' N'
73
- goto type_done
55
+ .return (' n' , ' repr_get_attr_num' , ' repr_bind_attr_num' )
74
56
prim_str:
75
- get_attr_op = ' repr_get_attr_str'
76
- set_attr_op = ' repr_bind_attr_str'
77
- coerce_reg_type = ' S'
78
- goto type_done
79
- type_done:
57
+ .return (' s' , ' repr_get_attr_str' , ' repr_bind_attr_str' )
58
+ .end
59
+
60
+
61
+
62
+ . sub ' attribute_6model' :method :multi (_ , [' PAST' ;' Var' ])
63
+ .param pmc node
64
+ .param pmc bindpost
65
+
66
+ .local pmc ops
67
+ $P0 = get_hll_global [' POST' ], ' Ops'
68
+ ops = $P0 . ' new' (' node' = >node )
69
+
70
+ unless bindpost goto have_bindpost
71
+ $S0 = bindpost . ' result' ()
72
+ bindpost = $P0 . ' new' (' result' = >$S0 )
73
+ have_bindpost:
74
+
75
+ .local string name
76
+ name = node . ' name' ()
77
+ name = self . ' escape' (name )
78
+
79
+ # See if we have a type. If so, use it to determine what op to use
80
+ # and what the register type will be.
81
+ .local string get_attr_op , set_attr_op , coerce_reg_type
82
+ (coerce_reg_type , get_attr_op , set_attr_op ) = self . ' attribute_6model_type' (node )
80
83
81
84
# We have three cases here.
82
85
# 0 children = use self
@@ -113,11 +116,8 @@ some PAST that will produce it or a name that it can be looked up by.
113
116
. tailcall self . ' vivify' (node , ops , fetchop , storeop )
114
117
115
118
attribute_bind:
116
- if coerce_reg_type == ' P' goto attribute_bind_coerced
117
- $P0 = self . ' uniquereg' (coerce_reg_type )
118
- ops . ' push_pirop' (' set' , $P0 , bindpost )
119
- bindpost = $P0
120
- attribute_bind_coerced:
119
+ bindpost = self . ' coerce' (bindpost , coerce_reg_type )
120
+ ops . ' push' (bindpost )
121
121
ops . ' push_pirop' (set_attr_op , call_on , name , bindpost )
122
122
ops . ' result' (bindpost )
123
123
.return (ops )
@@ -144,11 +144,8 @@ some PAST that will produce it or a name that it can be looked up by.
144
144
. tailcall self . ' vivify' (node , ops , fetchop , storeop )
145
145
146
146
attribute_bind_handle:
147
- if coerce_reg_type == ' P' goto attribute_bind_handle_coerced
148
- $P0 = self . ' uniquereg' (coerce_reg_type )
149
- ops . ' push_pirop' (' set' , $P0 , bindpost )
150
- bindpost = $P0
151
- attribute_bind_handle_coerced:
147
+ bindpost = self . ' coerce' (bindpost , coerce_reg_type )
148
+ ops . ' push' (bindpost )
152
149
ops . ' push_pirop' (set_attr_op , call_on , handle , name , bindpost )
153
150
ops . ' result' (bindpost )
154
151
.return (ops )
0 commit comments