public override void ExitLocalVariableDeclarationStatement([NotNull] SBP.LocalVariableDeclarationStatementContext context) { TypeReference type = m_variableType; VariableModifier modifier = m_variableModifier; if (type == null) { return; } if (modifier == VariableModifier.None) { if (type.Type == typeof(VarSpecifiedType)) { if (m_variables[0].Value.IsError()) { return; // Just leave; no point in spending more time on this variable. } else if (m_variables[0].Value.DataType != null) { type = m_variables[0].Value.DataType; } else if (m_variables[0].Value.ExpressionCode != null) { type = new TypeReference(m_variables[0].Value.ExpressionCode.Type); } else { throw new NotImplementedException("Unknown value type for assignment."); } } foreach (var variable in m_variables) { if (!type.Type.IsAssignableFrom(variable.Value.DataType.Type)) { throw new NotImplementedException("Variables assignment of incompatible type."); } if (m_scopeStack.Peek().StatementCount > 0) { var scope = m_scopeStack.Peek(); var v = scope.AddVariable(variable.Name, type, null, EntryModifiers.Private); scope.AddStatementCode(Expression.Assign(v.VariableExpression, variable.Value.ExpressionCode)); } else { m_scopeStack.Peek().AddVariable(variable.Name, type, variable.Value, EntryModifiers.Private); } } } else // Some kind of static { throw new NotImplementedException(); } }
public override void EnterLocalVariableDeclarationStatement([NotNull] SBP.LocalVariableDeclarationStatementContext context) { this.AddEnterStatement(context); // TODO: Not if no initializer, and only for static if setting. m_variableModifier = VariableModifier.None; }