public void Visit(DeclarationAssignment n) { n.AstType.Accept(this); Helpers.WriteColor($" {n.DestinationName}", ConsoleColor.Green, ConsoleColor.Black); Helpers.Write(" = "); n.Source.Accept(this); }
public SemanticAtom Visit(DeclarationAssignment n) { var destinationType = CurrentBlock.LookupIdentifierType(n.DestinationName, n.Location); var sourceType = n.Source.Accept(this) as SemanticType; if (!destinationType.IsAssignableFrom(sourceType)) { Globals.Errors.Add($"[{n.Location.StartLine}, {n.Location.StartColumn}] Source expression ({sourceType.Name}) is not assignable to {n.DestinationName} ({destinationType.Name})."); } return(destinationType); }
public void Visit(DeclarationAssignment n) { Globals.Builder.Start($"assignment ({n.DestinationName}) [{n.Location.StartLine}, {n.Location.StartColumn}]"); GetIdentifier(n.DestinationName); // rax has pointer to location. Globals.Builder.WriteUnaryOp("push", "rax"); n.Source.Accept(this); Globals.Builder.WriteUnaryOp("pop", "r10"); Globals.Builder.WriteBinaryOp("mov", "[r10]", "rax"); Globals.Builder.End($"assignment ({n.DestinationName}) [{n.Location.EndLine}, {n.Location.EndColumn}]"); }
public void Visit(DeclarationAssignment n) { Helpers.WriteLine($"{_tab}{n.Text} ({n.DestinationName}) [{n.Location.StartLine}, {n.Location.StartColumn}]"); Tab(); Helpers.WriteLine($"{_tab}Type"); Tab(); n.AstType.Accept(this); Untab(); Helpers.WriteLine($"{_tab}Source"); Tab(); n.Source.Accept(this); Untab(); Untab(); }
public SemanticAtom Visit(DeclarationAssignment n) { var utilizedType = (UtilizedType)n.AstType.Accept(this); var local = new Local(n.DestinationName, _localPosition++, utilizedType, n.Location); AddToGlobalUtilization(utilizedType, s => { local.RealizedType = s; }); if (BlockStack.Peek().Locals.ContainsKey(local.Name)) { Globals.Errors.Add( $"[{local.DeclarationLocation.StartLine}, {local.DeclarationLocation.StartColumn}] Local ({local.Name}) is already defined in current block of {CurrentMethod.Name}."); } else { BlockStack.Peek().Locals.Add(local.Name, local); } n.Source.Accept(this); return(local); }