Exemplo n.º 1
0
LocalVariable GetOrCreateLocalVariable(Block block, string name, LocalVariable.Flags flags, FullNamedExpression typeExpr, Location loc)
{
	INamedBlockVariable existing = null;
	LocalVariable li = null;

	if (!parsing_playscript) {
		if (block.ParametersBlock.TopBlock.GetLocalName (name, block, ref existing)) {
			if (existing is LocalVariable) {
				li = existing as LocalVariable;
				if (li.TypeExpr != null && existing.TypeExpr != null && li.TypeExpr.Equals (existing.TypeExpr)) {
					report.Warning (7138, 1, loc, "Variable is declared more than once.");
					li.DeclFlags |= LocalVariable.Flags.AsIgnoreMultiple;
					return li;
				}
			}
		}
	}
	
	li = new LocalVariable(block, name, flags, loc);
	li.TypeExpr = typeExpr;

	block.AddLocalName (li);
	
	return li;
}