end
# Make a new variable read
- fun make_var_read(variable: Variable): AVarExpr
+ fun make_var_read(variable: Variable, mtype: MType): AVarExpr
do
- return new AVarExpr.make(variable)
+ return new AVarExpr.make(variable, mtype)
end
# Make a new variable assignment
place.replace_with(nvar)
self.variable_cache = variable
end
- return new AVarExpr.make(variable)
+ return new AVarExpr.make(variable, variable.declared_type.as(not null))
end
private var variable_cache: nullable Variable
end
redef class AVarExpr
- private init make(v: Variable)
+ private init make(v: Variable, mtype: MType)
do
_n_id = new TId
variable = v
- mtype = v.declared_type
+ self.mtype = mtype
end
end
do
var variable = self.variable.as(not null)
- var nread = v.builder.make_var_read(variable)
+ var nread = v.builder.make_var_read(variable, read_type.as(not null))
+
var nnewvalue = v.builder.make_call(nread, reassign_callsite.mproperty, [n_value])
var nwrite = v.builder.make_var_assign(variable, nnewvalue)
var readtype = v.get_variable(self, variable)
if readtype == null then return
+ read_type = readtype
+
var writetype = variable.declared_type
if writetype == null then return
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+var x
+x = 1
+x += 1
+x.output