public void VisitIdentifier(DMASTIdentifier identifier) { var name = identifier.Identifier; switch (name) { case "src": Result = new Expressions.Src(identifier.Location, _dmObject.Path); break; case "usr": Result = new Expressions.Usr(identifier.Location); break; case "args": Result = new Expressions.Args(identifier.Location); break; default: { DMProc.LocalVariable localVar = _proc?.GetLocalVariable(name); if (localVar != null && _scopeMode == "normal") { Result = new Expressions.Local(identifier.Location, localVar); return; } int?procGlobalId = _proc?.GetGlobalVariableId(name); if (procGlobalId != null) { Result = new Expressions.GlobalField(identifier.Location, DMObjectTree.Globals[procGlobalId.Value].Type, procGlobalId.Value); return; } var field = _dmObject?.GetVariable(name); if (field != null && _scopeMode == "normal") { Result = new Expressions.Field(identifier.Location, field); return; } int?globalId = _dmObject?.GetGlobalVariableId(name); if (globalId != null) { Result = new Expressions.GlobalField(identifier.Location, DMObjectTree.Globals[globalId.Value].Type, globalId.Value); return; } throw new CompileErrorException(identifier.Location, $"Unknown identifier \"{name}\""); } } }
public Local(Location location, DMProc.LocalVariable localVar) : base(location, localVar.Type) { LocalVar = localVar; }