public FrameResource Visit(IdentifierExpression expression) { var resource = _scope.GetOrDefault(expression.Name); if (resource == null) { throw new Exception(); // TODO } var copyResource = _frame.Allocate(resource.Type); _context.Emit(new Instruction(Opcode.Mov, copyResource.Operand, resource.Operand)); return(copyResource); }
public bool TryDefine(string name, TypeBase type, out FrameResource resource) { resource = null; if (IsDefined(name)) { return(false); } resource = Frame.Allocate(type, false); _identifiers.Add(name, resource); return(true); }