public void Accept(BinaryOperationNode node) { switch (node.BinaryOperation) { case BinaryOperation.Assignment: node.Right.Visit(this); if (node.Left is IdentifierNode) { string identifier = ((IdentifierNode)node.Left).Identifier; if (table.ContainsGlobalSymbol(identifier)) { method.Emit(node.SourceLocation, InstructionType.StoreGlobalVariable, table.GetGlobalSymbol(identifier)); method.Emit(node.SourceLocation, InstructionType.LoadGlobalVariable, table.GetGlobalSymbol(identifier)); } else { if (!table.ContainsSymbol(identifier)) table.AddSymbol(identifier); method.Emit(node.SourceLocation, InstructionType.StoreLocal, table.GetSymbol(identifier)); method.Emit(node.SourceLocation, InstructionType.LoadLocal, table.GetSymbol(identifier)); } } else if (node.Left is AttributeAccessNode) { AttributeAccessNode accessor = node.Left as AttributeAccessNode; accessor.Left.Visit(this); if (!module.ConstantPool.ContainsValue(accessor.Right)) module.ConstantPool.Add(accessor.Right.GetHashCode(), accessor.Right); method.Emit(node.SourceLocation, InstructionType.StoreAttribute, accessor.Right.GetHashCode()); accessor.Left.Visit(this); } else if (node.Left is ListAccessNode) { ListAccessNode access = node.Left as ListAccessNode; access.Element.Visit(this); access.Target.Visit(this); method.Emit(node.SourceLocation, InstructionType.StoreListElement); } else if (node.Left is UnaryOperationNode) { var unop = node.Left as UnaryOperationNode; if (unop.UnaryOperation == UnaryOperation.Dereference) { unop.Target.Visit(this); method.Emit(node.SourceLocation, InstructionType.StoreReference); } } break; case BinaryOperation.Swap: method.Emit(node.SourceLocation, InstructionType.Push, table.GetSymbol(((IdentifierNode)node.Left).Identifier)); method.Emit(node.SourceLocation, InstructionType.Swap, table.GetSymbol(((IdentifierNode)node.Right).Identifier)); break; default: node.VisitChildren(this); method.Emit(node.SourceLocation, InstructionType.BinaryOperation, (int)node.BinaryOperation); break; } }
public void Accept(BinaryOperationNode node) { }